1; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV 2 3; ModuleID = 'RelationalOperators.cl' 4source_filename = "RelationalOperators.cl" 5target 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" 6target triple = "spirv32-unknown-unknown" 7 8; CHECK-SPIRV: %[[bool:[0-9]+]] = OpTypeBool 9; CHECK-SPIRV: %[[bool2:[0-9]+]] = OpTypeVector %[[bool]] 2 10 11; CHECK-SPIRV: OpFunction 12; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 13; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 14; CHECK-SPIRV: %{{[0-9]+}} = OpUGreaterThan %[[bool2]] %[[A]] %[[B]] 15; CHECK-SPIRV: OpFunctionEnd 16 17; kernel void testUGreaterThan(uint2 a, uint2 b, global int2 *res) { 18; res[0] = a > b; 19; } 20 21; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 22define dso_local spir_kernel void @testUGreaterThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 { 23entry: 24 %cmp = icmp ugt <2 x i32> %a, %b 25 %sext = sext <2 x i1> %cmp to <2 x i32> 26 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 27 ret void 28} 29 30; CHECK-SPIRV: OpFunction 31; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 32; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 33; CHECK-SPIRV: %{{[0-9]+}} = OpSGreaterThan %[[bool2]] %[[A]] %[[B]] 34; CHECK-SPIRV: OpFunctionEnd 35 36; kernel void testSGreaterThan(int2 a, int2 b, global int2 *res) { 37; res[0] = a > b; 38; } 39 40; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 41define dso_local spir_kernel void @testSGreaterThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !11 !kernel_arg_base_type !12 !kernel_arg_type_qual !7 { 42entry: 43 %cmp = icmp sgt <2 x i32> %a, %b 44 %sext = sext <2 x i1> %cmp to <2 x i32> 45 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 46 ret void 47} 48 49; CHECK-SPIRV: OpFunction 50; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 51; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 52; CHECK-SPIRV: %{{[0-9]+}} = OpUGreaterThanEqual %[[bool2]] %[[A]] %[[B]] 53; CHECK-SPIRV: OpFunctionEnd 54 55; kernel void testUGreaterThanEqual(uint2 a, uint2 b, global int2 *res) { 56; res[0] = a >= b; 57; } 58 59; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 60define dso_local spir_kernel void @testUGreaterThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 { 61entry: 62 %cmp = icmp uge <2 x i32> %a, %b 63 %sext = sext <2 x i1> %cmp to <2 x i32> 64 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 65 ret void 66} 67 68; CHECK-SPIRV: OpFunction 69; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 70; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 71; CHECK-SPIRV: %{{[0-9]+}} = OpSGreaterThanEqual %[[bool2]] %[[A]] %[[B]] 72; CHECK-SPIRV: OpFunctionEnd 73 74; kernel void testSGreaterThanEqual(int2 a, int2 b, global int2 *res) { 75; res[0] = a >= b; 76; } 77 78; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 79define dso_local spir_kernel void @testSGreaterThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !11 !kernel_arg_base_type !12 !kernel_arg_type_qual !7 { 80entry: 81 %cmp = icmp sge <2 x i32> %a, %b 82 %sext = sext <2 x i1> %cmp to <2 x i32> 83 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 84 ret void 85} 86 87; CHECK-SPIRV: OpFunction 88; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 89; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 90; CHECK-SPIRV: %{{[0-9]+}} = OpULessThan %[[bool2]] %[[A]] %[[B]] 91; CHECK-SPIRV: OpFunctionEnd 92 93; kernel void testULessThan(uint2 a, uint2 b, global int2 *res) { 94; res[0] = a < b; 95; } 96 97; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 98define dso_local spir_kernel void @testULessThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 { 99entry: 100 %cmp = icmp ult <2 x i32> %a, %b 101 %sext = sext <2 x i1> %cmp to <2 x i32> 102 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 103 ret void 104} 105 106; CHECK-SPIRV: OpFunction 107; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 108; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 109; CHECK-SPIRV: %{{[0-9]+}} = OpSLessThan %[[bool2]] %[[A]] %[[B]] 110; CHECK-SPIRV: OpFunctionEnd 111 112; kernel void testSLessThan(int2 a, int2 b, global int2 *res) { 113; res[0] = a < b; 114; } 115 116; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 117define dso_local spir_kernel void @testSLessThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !11 !kernel_arg_base_type !12 !kernel_arg_type_qual !7 { 118entry: 119 %cmp = icmp slt <2 x i32> %a, %b 120 %sext = sext <2 x i1> %cmp to <2 x i32> 121 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 122 ret void 123} 124 125; CHECK-SPIRV: OpFunction 126; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 127; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 128; CHECK-SPIRV: %{{[0-9]+}} = OpULessThanEqual %[[bool2]] %[[A]] %[[B]] 129; CHECK-SPIRV: OpFunctionEnd 130 131; kernel void testULessThanEqual(uint2 a, uint2 b, global int2 *res) { 132; res[0] = a <= b; 133; } 134 135; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 136define dso_local spir_kernel void @testULessThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !5 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 { 137entry: 138 %cmp = icmp ule <2 x i32> %a, %b 139 %sext = sext <2 x i1> %cmp to <2 x i32> 140 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 141 ret void 142} 143 144; CHECK-SPIRV: OpFunction 145; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 146; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 147; CHECK-SPIRV: %{{[0-9]+}} = OpSLessThanEqual %[[bool2]] %[[A]] %[[B]] 148; CHECK-SPIRV: OpFunctionEnd 149 150; kernel void testSLessThanEqual(int2 a, int2 b, global int2 *res) { 151; res[0] = a <= b; 152; } 153 154; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 155define dso_local spir_kernel void @testSLessThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !11 !kernel_arg_base_type !12 !kernel_arg_type_qual !7 { 156entry: 157 %cmp = icmp sle <2 x i32> %a, %b 158 %sext = sext <2 x i1> %cmp to <2 x i32> 159 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 160 ret void 161} 162 163; CHECK-SPIRV: OpFunction 164; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 165; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 166; CHECK-SPIRV: %{{[0-9]+}} = OpFOrdEqual %[[bool2]] %[[A]] %[[B]] 167; CHECK-SPIRV: OpFunctionEnd 168 169; kernel void testFOrdEqual(float2 a, float2 b, global int2 *res) { 170; res[0] = a == b; 171; } 172 173; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 174define dso_local spir_kernel void @testFOrdEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !13 !kernel_arg_base_type !14 !kernel_arg_type_qual !7 { 175entry: 176 %cmp = fcmp oeq <2 x float> %a, %b 177 %sext = sext <2 x i1> %cmp to <2 x i32> 178 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 179 ret void 180} 181 182; CHECK-SPIRV: OpFunction 183; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 184; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 185; CHECK-SPIRV: %{{[0-9]+}} = OpFUnordNotEqual %[[bool2]] %[[A]] %[[B]] 186; CHECK-SPIRV: OpFunctionEnd 187 188; kernel void testFUnordNotEqual(float2 a, float2 b, global int2 *res) { 189; res[0] = a != b; 190; } 191 192; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 193define dso_local spir_kernel void @testFUnordNotEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !13 !kernel_arg_base_type !14 !kernel_arg_type_qual !7 { 194entry: 195 %cmp = fcmp une <2 x float> %a, %b 196 %sext = sext <2 x i1> %cmp to <2 x i32> 197 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 198 ret void 199} 200 201; CHECK-SPIRV: OpFunction 202; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 203; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 204; CHECK-SPIRV: %{{[0-9]+}} = OpFOrdGreaterThan %[[bool2]] %[[A]] %[[B]] 205; CHECK-SPIRV: OpFunctionEnd 206 207; kernel void testFOrdGreaterThan(float2 a, float2 b, global int2 *res) { 208; res[0] = a > b; 209; } 210 211; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 212define dso_local spir_kernel void @testFOrdGreaterThan(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !13 !kernel_arg_base_type !14 !kernel_arg_type_qual !7 { 213entry: 214 %cmp = fcmp ogt <2 x float> %a, %b 215 %sext = sext <2 x i1> %cmp to <2 x i32> 216 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 217 ret void 218} 219 220; CHECK-SPIRV: OpFunction 221; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 222; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 223; CHECK-SPIRV: %{{[0-9]+}} = OpFOrdGreaterThanEqual %[[bool2]] %[[A]] %[[B]] 224; CHECK-SPIRV: OpFunctionEnd 225 226; kernel void testFOrdGreaterThanEqual(float2 a, float2 b, global int2 *res) { 227; res[0] = a >= b; 228; } 229 230; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 231define dso_local spir_kernel void @testFOrdGreaterThanEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !13 !kernel_arg_base_type !14 !kernel_arg_type_qual !7 { 232entry: 233 %cmp = fcmp oge <2 x float> %a, %b 234 %sext = sext <2 x i1> %cmp to <2 x i32> 235 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 236 ret void 237} 238 239; CHECK-SPIRV: OpFunction 240; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 241; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 242; CHECK-SPIRV: %{{[0-9]+}} = OpFOrdLessThan %[[bool2]] %[[A]] %[[B]] 243; CHECK-SPIRV: OpFunctionEnd 244 245; kernel void testFOrdLessThan(float2 a, float2 b, global int2 *res) { 246; res[0] = a < b; 247; } 248 249; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 250define dso_local spir_kernel void @testFOrdLessThan(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !13 !kernel_arg_base_type !14 !kernel_arg_type_qual !7 { 251entry: 252 %cmp = fcmp olt <2 x float> %a, %b 253 %sext = sext <2 x i1> %cmp to <2 x i32> 254 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 255 ret void 256} 257 258; CHECK-SPIRV: OpFunction 259; CHECK-SPIRV-NEXT: %[[A:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 260; CHECK-SPIRV-NEXT: %[[B:[0-9]+]] = OpFunctionParameter %{{[0-9]+}} 261; CHECK-SPIRV: %{{[0-9]+}} = OpFOrdLessThanEqual %[[bool2]] %[[A]] %[[B]] 262; CHECK-SPIRV: OpFunctionEnd 263 264; kernel void testFOrdLessThanEqual(float2 a, float2 b, global int2 *res) { 265; res[0] = a <= b; 266; } 267 268; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn writeonly 269define dso_local spir_kernel void @testFOrdLessThanEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr #0 !kernel_arg_addr_space !3 !kernel_arg_access_qual !4 !kernel_arg_type !13 !kernel_arg_base_type !14 !kernel_arg_type_qual !7 { 270entry: 271 %cmp = fcmp ole <2 x float> %a, %b 272 %sext = sext <2 x i1> %cmp to <2 x i32> 273 store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8, !tbaa !8 274 ret void 275} 276 277attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn writeonly "frame-pointer"="none" "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="false" } 278 279!llvm.module.flags = !{!0} 280!opencl.ocl.version = !{!1} 281!opencl.spir.version = !{!1} 282!llvm.ident = !{!2} 283 284!0 = !{i32 1, !"wchar_size", i32 4} 285!1 = !{i32 2, i32 0} 286!2 = !{!"clang version 14.0.0 (https://github.com/llvm/llvm-project.git 881b6a009fb6e2dd5fb924524cd6eacd14148a08)"} 287!3 = !{i32 0, i32 0, i32 1} 288!4 = !{!"none", !"none", !"none"} 289!5 = !{!"uint2", !"uint2", !"int2*"} 290!6 = !{!"uint __attribute__((ext_vector_type(2)))", !"uint __attribute__((ext_vector_type(2)))", !"int __attribute__((ext_vector_type(2)))*"} 291!7 = !{!"", !"", !""} 292!8 = !{!9, !9, i64 0} 293!9 = !{!"omnipotent char", !10, i64 0} 294!10 = !{!"Simple C/C++ TBAA"} 295!11 = !{!"int2", !"int2", !"int2*"} 296!12 = !{!"int __attribute__((ext_vector_type(2)))", !"int __attribute__((ext_vector_type(2)))", !"int __attribute__((ext_vector_type(2)))*"} 297!13 = !{!"float2", !"float2", !"int2*"} 298!14 = !{!"float __attribute__((ext_vector_type(2)))", !"float __attribute__((ext_vector_type(2)))", !"int __attribute__((ext_vector_type(2)))*"} 299