1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
4 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s --translator-compatibility-mode -o - | FileCheck %s --check-prefix=CHECK-COMPAT
5 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s --translator-compatibility-mode -o - -filetype=obj | spirv-val %}
7 ; CHECK-DAG: OpName [[EQ:%.*]] "test_eq"
8 ; CHECK-DAG: OpName [[NE:%.*]] "test_ne"
9 ; CHECK-COMPAT-DAG: OpName [[EQ:%.*]] "test_eq"
10 ; CHECK-COMPAT-DAG: OpName [[NE:%.*]] "test_ne"
11 ; CHECK-DAG: OpName [[ULT:%.*]] "test_ult"
12 ; CHECK-DAG: OpName [[SLT:%.*]] "test_slt"
13 ; CHECK-DAG: OpName [[ULE:%.*]] "test_ule"
14 ; CHECK-DAG: OpName [[SLE:%.*]] "test_sle"
15 ; CHECK-DAG: OpName [[UGT:%.*]] "test_ugt"
16 ; CHECK-DAG: OpName [[SGT:%.*]] "test_sgt"
17 ; CHECK-DAG: OpName [[UGE:%.*]] "test_uge"
18 ; CHECK-DAG: OpName [[SGE:%.*]] "test_sge"
20 ;; FIXME: Translator uses OpIEqual/OpINotEqual for test_eq/test_ne cases
21 ; CHECK: [[EQ]] = OpFunction
22 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
23 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
25 ; CHECK-NEXT: [[R:%.*]] = OpPtrEqual {{%.+}} [[A]] [[B]]
26 ; CHECK-NEXT: OpReturnValue [[R]]
27 ; CHECK-NEXT: OpFunctionEnd
28 ; CHECK-COMPAT: [[EQ]] = OpFunction
29 ; CHECK-COMPAT-NOT: OpPtrEqual
30 ; CHECK-COMPAT: OpFunctionEnd
31 define i1 @test_eq(i16* %a, i16* %b) {
32 %r = icmp eq i16* %a, %b
36 ; CHECK: [[NE]] = OpFunction
37 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
38 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
40 ; CHECK-NEXT: [[R:%.*]] = OpPtrNotEqual {{%.+}} [[A]] [[B]]
41 ; CHECK-NEXT: OpReturnValue [[R]]
42 ; CHECK-NEXT: OpFunctionEnd
43 ; CHECK-COMPAT: [[NE]] = OpFunction
44 ; CHECK-COMPAT-NOT: OpPtrNotEqual
45 ; CHECK-COMPAT: OpFunctionEnd
46 define i1 @test_ne(i16* %a, i16* %b) {
47 %r = icmp ne i16* %a, %b
51 ; CHECK: [[SLT]] = OpFunction
52 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
53 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
55 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
56 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
57 ; CHECK: [[R:%.*]] = OpSLessThan {{%.+}} [[AI]] [[BI]]
58 ; CHECK-NEXT: OpReturnValue [[R]]
59 ; CHECK-NEXT: OpFunctionEnd
60 define i1 @test_slt(i16* %a, i16* %b) {
61 %r = icmp slt i16* %a, %b
65 ; CHECK: [[ULT]] = OpFunction
66 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
67 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
69 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
70 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
71 ; CHECK: [[R:%.*]] = OpULessThan {{%.+}} [[AI]] [[BI]]
72 ; CHECK-NEXT: OpReturnValue [[R]]
73 ; CHECK-NEXT: OpFunctionEnd
74 define i1 @test_ult(i16* %a, i16* %b) {
75 %r = icmp ult i16* %a, %b
79 ; CHECK: [[ULE]] = OpFunction
80 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
81 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
83 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
84 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
85 ; CHECK: [[R:%.*]] = OpULessThanEqual {{%.+}} [[AI]] [[BI]]
86 ; CHECK-NEXT: OpReturnValue [[R]]
87 ; CHECK-NEXT: OpFunctionEnd
88 define i1 @test_ule(i16* %a, i16* %b) {
89 %r = icmp ule i16* %a, %b
93 ; CHECK: [[SLE]] = OpFunction
94 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
95 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
97 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
98 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
99 ; CHECK: [[R:%.*]] = OpSLessThanEqual {{%.+}} [[AI]] [[BI]]
100 ; CHECK-NEXT: OpReturnValue [[R]]
101 ; CHECK-NEXT: OpFunctionEnd
102 define i1 @test_sle(i16* %a, i16* %b) {
103 %r = icmp sle i16* %a, %b
107 ; CHECK: [[UGT]] = OpFunction
108 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
109 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
110 ; CHECK-NEXT: OpLabel
111 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
112 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
113 ; CHECK: [[R:%.*]] = OpUGreaterThan {{%.+}} [[AI]] [[BI]]
114 ; CHECK-NEXT: OpReturnValue [[R]]
115 ; CHECK-NEXT: OpFunctionEnd
116 define i1 @test_ugt(i16* %a, i16* %b) {
117 %r = icmp ugt i16* %a, %b
121 ; CHECK: [[SGT]] = OpFunction
122 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
123 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
124 ; CHECK-NEXT: OpLabel
125 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
126 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
127 ; CHECK: [[R:%.*]] = OpSGreaterThan {{%.+}} [[AI]] [[BI]]
128 ; CHECK-NEXT: OpReturnValue [[R]]
129 ; CHECK-NEXT: OpFunctionEnd
130 define i1 @test_sgt(i16* %a, i16* %b) {
131 %r = icmp sgt i16* %a, %b
135 ; CHECK: [[UGE]] = OpFunction
136 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
137 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
138 ; CHECK-NEXT: OpLabel
139 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
140 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
141 ; CHECK: [[R:%.*]] = OpUGreaterThanEqual {{%.+}} [[AI]] [[BI]]
142 ; CHECK-NEXT: OpReturnValue [[R]]
143 ; CHECK-NEXT: OpFunctionEnd
144 define i1 @test_uge(i16* %a, i16* %b) {
145 %r = icmp uge i16* %a, %b
149 ; CHECK: [[SGE]] = OpFunction
150 ; CHECK-NEXT: [[A:%.*]] = OpFunctionParameter
151 ; CHECK-NEXT: [[B:%.*]] = OpFunctionParameter
152 ; CHECK-NEXT: OpLabel
153 ; CHECK-NEXT: [[AI:%.*]] = OpConvertPtrToU {{%.+}} [[A]]
154 ; CHECK-NEXT: [[BI:%.*]] = OpConvertPtrToU {{%.+}} [[B]]
155 ; CHECK: [[R:%.*]] = OpSGreaterThanEqual {{%.+}} [[AI]] [[BI]]
156 ; CHECK-NEXT: OpReturnValue [[R]]
157 ; CHECK-NEXT: OpFunctionEnd
158 define i1 @test_sge(i16* %a, i16* %b) {
159 %r = icmp sge i16* %a, %b