• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llvm-as < %s | llvm-spirv -spirv-text | FileCheck %s
2
3target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
4target triple = "spir-unknown-unknown"
5
6; CHECK: 3 Source 3 200000
7
8; CHECK: Name [[Pointer:[0-9]+]] "object"
9; CHECK: Name [[ComparatorPtr:[0-9]+]] "expected"
10; CHECK: Name [[Value:[0-9]+]] "desired"
11; CHECK: 4 TypeInt [[int:[0-9]+]] 32 0
12; CHECK: Constant [[int]] [[DeviceScope:[0-9]+]] 1
13; CHECK: Constant [[int]] [[SequentiallyConsistent_MS:[0-9]+]] 16
14; CHECK: 4 TypePointer [[int_ptr:[0-9]+]] 8 [[int]]
15; CHECK: 2 TypeBool [[bool:[0-9]+]]
16
17; Function Attrs: nounwind
18define spir_func void @test(i32 addrspace(4)* %object, i32 addrspace(4)* %expected, i32 %desired) #0 {
19; CHECK: FunctionParameter [[int_ptr]] [[Pointer]]
20; CHECK: FunctionParameter [[int_ptr]] [[ComparatorPtr]]
21; CHECK: FunctionParameter [[int]] [[Value]]
22
23entry:
24  %object.addr = alloca i32 addrspace(4)*, align 4
25  %expected.addr = alloca i32 addrspace(4)*, align 4
26  %desired.addr = alloca i32, align 4
27  %strong_res = alloca i8, align 1
28  %res = alloca i8, align 1
29  %weak_res = alloca i8, align 1
30  store i32 addrspace(4)* %object, i32 addrspace(4)** %object.addr, align 4
31  store i32 addrspace(4)* %expected, i32 addrspace(4)** %expected.addr, align 4
32  store i32 %desired, i32* %desired.addr, align 4
33  %0 = load i32 addrspace(4)*, i32 addrspace(4)** %object.addr, align 4
34  %1 = load i32 addrspace(4)*, i32 addrspace(4)** %expected.addr, align 4
35  %2 = load i32, i32* %desired.addr, align 4
36
37  %call = call spir_func zeroext i1 @_Z30atomic_compare_exchange_strongPVU3AS4U7_AtomiciPU3AS4ii(i32 addrspace(4)* %0, i32 addrspace(4)* %1, i32 %2)
38; CHECK: Load [[int]] [[Comparator:[0-9]+]] [[ComparatorPtr]]
39; CHECK-NEXT: 9 AtomicCompareExchange [[int]] [[Result:[0-9]+]] [[Pointer]] [[DeviceScope]] [[SequentiallyConsistent_MS]] [[SequentiallyConsistent_MS]] [[Value]] [[Comparator]]
40; CHECK-NEXT: Store [[ComparatorPtr]] [[Result]]
41; CHECK-NEXT: IEqual [[bool]] [[CallRes:[0-9]+]] [[Result]] [[Comparator]]
42; CHECK-NOT: [[Result]]
43  %frombool = zext i1 %call to i8
44  store i8 %frombool, i8* %strong_res, align 1
45  %3 = load i8, i8* %strong_res, align 1
46  %tobool = trunc i8 %3 to i1
47  %lnot = xor i1 %tobool, true
48  %frombool1 = zext i1 %lnot to i8
49  store i8 %frombool1, i8* %res, align 1
50  %4 = load i32 addrspace(4)*, i32 addrspace(4)** %object.addr, align 4
51  %5 = load i32 addrspace(4)*, i32 addrspace(4)** %expected.addr, align 4
52  %6 = load i32, i32* %desired.addr, align 4
53
54  %call2 = call spir_func zeroext i1 @_Z28atomic_compare_exchange_weakPVU3AS4U7_AtomiciPU3AS4ii(i32 addrspace(4)* %4, i32 addrspace(4)* %5, i32 %6)
55; CHECK: Load [[int]] [[ComparatorWeak:[0-9]+]] [[ComparatorPtr]]
56; CHECK-NEXT: 9 AtomicCompareExchangeWeak [[int]] [[Result:[0-9]+]] [[Pointer]] [[DeviceScope]] [[SequentiallyConsistent_MS]] [[SequentiallyConsistent_MS]] [[Value]] [[ComparatorWeak]]
57; CHECK-NEXT: Store [[ComparatorPtr]] [[Result]]
58; CHECK-NEXT: IEqual [[bool]] [[CallRes:[0-9]+]] [[Result]] [[ComparatorWeak]]
59; CHECK-NOT: [[Result]]
60
61  %frombool3 = zext i1 %call2 to i8
62  store i8 %frombool3, i8* %weak_res, align 1
63  %7 = load i8, i8* %weak_res, align 1
64  %tobool4 = trunc i8 %7 to i1
65  %lnot5 = xor i1 %tobool4, true
66  %frombool6 = zext i1 %lnot5 to i8
67  store i8 %frombool6, i8* %res, align 1
68  ret void
69}
70
71declare spir_func zeroext i1 @_Z30atomic_compare_exchange_strongPVU3AS4U7_AtomiciPU3AS4ii(i32 addrspace(4)*, i32 addrspace(4)*, i32) #1
72
73declare spir_func zeroext i1 @_Z28atomic_compare_exchange_weakPVU3AS4U7_AtomiciPU3AS4ii(i32 addrspace(4)*, i32 addrspace(4)*, i32) #1
74; RUN: llvm-as < %s | llvm-spirv -spirv-text | FileCheck %s
75
76attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
77attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
78
79!opencl.enable.FP_CONTRACT = !{}
80!opencl.spir.version = !{!0}
81!opencl.ocl.version = !{!1}
82!opencl.used.extensions = !{!2}
83!opencl.used.optional.core.features = !{!2}
84!opencl.compiler.options = !{!2}
85
86
87!0 = !{i32 1, i32 2}
88!1 = !{i32 2, i32 0}
89!2 = !{}
90