1db7a2f34SJuneyoung Lee; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 25e4dbd7aSBjorn Pettersson; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2 | FileCheck %s 35e4dbd7aSBjorn Pettersson; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2 | FileCheck %s 4db7a2f34SJuneyoung Lee 5db7a2f34SJuneyoung Leedeclare void @use(<4 x i32>) 6db7a2f34SJuneyoung Leedeclare void @usef(<4 x float>) 7db7a2f34SJuneyoung Lee 8db7a2f34SJuneyoung Lee; Eliminating an insert is profitable. 9db7a2f34SJuneyoung Lee 10db7a2f34SJuneyoung Leedefine <16 x i1> @ins0_ins0_i8(i8 %x, i8 %y) { 11db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins0_ins0_i8( 12db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp eq i8 [[X:%.*]], [[Y:%.*]] 13db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <16 x i1> poison, i1 [[R_SCALAR]], i64 0 14db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <16 x i1> [[R]] 15db7a2f34SJuneyoung Lee; 16db7a2f34SJuneyoung Lee %i0 = insertelement <16 x i8> poison, i8 %x, i32 0 17db7a2f34SJuneyoung Lee %i1 = insertelement <16 x i8> poison, i8 %y, i32 0 18db7a2f34SJuneyoung Lee %r = icmp eq <16 x i8> %i0, %i1 19db7a2f34SJuneyoung Lee ret <16 x i1> %r 20db7a2f34SJuneyoung Lee} 21db7a2f34SJuneyoung Lee 22db7a2f34SJuneyoung Lee; Eliminating an insert is still profitable. Mismatch types on index is ok. 23db7a2f34SJuneyoung Lee 24db7a2f34SJuneyoung Leedefine <8 x i1> @ins5_ins5_i16(i16 %x, i16 %y) { 25db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins5_ins5_i16( 26db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp sgt i16 [[X:%.*]], [[Y:%.*]] 27db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i1> poison, i1 [[R_SCALAR]], i64 5 28db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <8 x i1> [[R]] 29db7a2f34SJuneyoung Lee; 30db7a2f34SJuneyoung Lee %i0 = insertelement <8 x i16> poison, i16 %x, i8 5 31db7a2f34SJuneyoung Lee %i1 = insertelement <8 x i16> poison, i16 %y, i32 5 32db7a2f34SJuneyoung Lee %r = icmp sgt <8 x i16> %i0, %i1 33db7a2f34SJuneyoung Lee ret <8 x i1> %r 34db7a2f34SJuneyoung Lee} 35db7a2f34SJuneyoung Lee 36db7a2f34SJuneyoung Lee; The new vector constant is calculated by constant folding. 37db7a2f34SJuneyoung Lee 38db7a2f34SJuneyoung Leedefine <2 x i1> @ins1_ins1_i64(i64 %x, i64 %y) { 39db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins1_ins1_i64( 40db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp sle i64 [[X:%.*]], [[Y:%.*]] 41db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i1> <i1 true, i1 false>, i1 [[R_SCALAR]], i64 1 42db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 43db7a2f34SJuneyoung Lee; 44db7a2f34SJuneyoung Lee %i0 = insertelement <2 x i64> zeroinitializer, i64 %x, i64 1 45db7a2f34SJuneyoung Lee %i1 = insertelement <2 x i64> <i64 1, i64 -1>, i64 %y, i32 1 46db7a2f34SJuneyoung Lee %r = icmp sle <2 x i64> %i0, %i1 47db7a2f34SJuneyoung Lee ret <2 x i1> %r 48db7a2f34SJuneyoung Lee} 49db7a2f34SJuneyoung Lee 50db7a2f34SJuneyoung Lee; The inserts are free, but it's still better to scalarize. 51db7a2f34SJuneyoung Lee 52db7a2f34SJuneyoung Leedefine <2 x i1> @ins0_ins0_f64(double %x, double %y) { 53db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins0_ins0_f64( 54db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = fcmp nnan ninf uge double [[X:%.*]], [[Y:%.*]] 55db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i1> poison, i1 [[R_SCALAR]], i64 0 56db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 57db7a2f34SJuneyoung Lee; 58db7a2f34SJuneyoung Lee %i0 = insertelement <2 x double> poison, double %x, i32 0 59db7a2f34SJuneyoung Lee %i1 = insertelement <2 x double> poison, double %y, i32 0 60db7a2f34SJuneyoung Lee %r = fcmp nnan ninf uge <2 x double> %i0, %i1 61db7a2f34SJuneyoung Lee ret <2 x i1> %r 62db7a2f34SJuneyoung Lee} 63db7a2f34SJuneyoung Lee 64db7a2f34SJuneyoung Lee; Negative test - mismatched indexes (but could fold this). 65db7a2f34SJuneyoung Lee 66db7a2f34SJuneyoung Leedefine <16 x i1> @ins1_ins0_i8(i8 %x, i8 %y) { 67db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins1_ins0_i8( 68db7a2f34SJuneyoung Lee; CHECK-NEXT: [[I0:%.*]] = insertelement <16 x i8> poison, i8 [[X:%.*]], i32 1 69db7a2f34SJuneyoung Lee; CHECK-NEXT: [[I1:%.*]] = insertelement <16 x i8> poison, i8 [[Y:%.*]], i32 0 70db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = icmp sle <16 x i8> [[I0]], [[I1]] 71db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <16 x i1> [[R]] 72db7a2f34SJuneyoung Lee; 73db7a2f34SJuneyoung Lee %i0 = insertelement <16 x i8> poison, i8 %x, i32 1 74db7a2f34SJuneyoung Lee %i1 = insertelement <16 x i8> poison, i8 %y, i32 0 75db7a2f34SJuneyoung Lee %r = icmp sle <16 x i8> %i0, %i1 76db7a2f34SJuneyoung Lee ret <16 x i1> %r 77db7a2f34SJuneyoung Lee} 78db7a2f34SJuneyoung Lee 79db7a2f34SJuneyoung Lee; Base vector does not have to be undef. 80db7a2f34SJuneyoung Lee 81db7a2f34SJuneyoung Leedefine <4 x i1> @ins0_ins0_i32(i32 %x, i32 %y) { 82db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins0_ins0_i32( 83db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp ne i32 [[X:%.*]], [[Y:%.*]] 84db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i1> poison, i1 [[R_SCALAR]], i64 0 85db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[R]] 86db7a2f34SJuneyoung Lee; 87db7a2f34SJuneyoung Lee %i0 = insertelement <4 x i32> zeroinitializer, i32 %x, i32 0 88db7a2f34SJuneyoung Lee %i1 = insertelement <4 x i32> poison, i32 %y, i32 0 89db7a2f34SJuneyoung Lee %r = icmp ne <4 x i32> %i0, %i1 90db7a2f34SJuneyoung Lee ret <4 x i1> %r 91db7a2f34SJuneyoung Lee} 92db7a2f34SJuneyoung Lee 93db7a2f34SJuneyoung Lee; Extra use is accounted for in cost calculation. 94db7a2f34SJuneyoung Lee 95db7a2f34SJuneyoung Leedefine <4 x i1> @ins0_ins0_i32_use(i32 %x, i32 %y) { 96db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins0_ins0_i32_use( 97db7a2f34SJuneyoung Lee; CHECK-NEXT: [[I0:%.*]] = insertelement <4 x i32> poison, i32 [[X:%.*]], i32 0 98db7a2f34SJuneyoung Lee; CHECK-NEXT: call void @use(<4 x i32> [[I0]]) 99db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp ugt i32 [[X]], [[Y:%.*]] 100db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i1> poison, i1 [[R_SCALAR]], i64 0 101db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[R]] 102db7a2f34SJuneyoung Lee; 103db7a2f34SJuneyoung Lee %i0 = insertelement <4 x i32> poison, i32 %x, i32 0 104db7a2f34SJuneyoung Lee call void @use(<4 x i32> %i0) 105db7a2f34SJuneyoung Lee %i1 = insertelement <4 x i32> poison, i32 %y, i32 0 106db7a2f34SJuneyoung Lee %r = icmp ugt <4 x i32> %i0, %i1 107db7a2f34SJuneyoung Lee ret <4 x i1> %r 108db7a2f34SJuneyoung Lee} 109db7a2f34SJuneyoung Lee 110db7a2f34SJuneyoung Lee; Extra use is accounted for in cost calculation. 111db7a2f34SJuneyoung Lee 112db7a2f34SJuneyoung Leedefine <4 x i1> @ins1_ins1_f32_use(float %x, float %y) { 113db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins1_ins1_f32_use( 114db7a2f34SJuneyoung Lee; CHECK-NEXT: [[I1:%.*]] = insertelement <4 x float> poison, float [[Y:%.*]], i32 1 115db7a2f34SJuneyoung Lee; CHECK-NEXT: call void @usef(<4 x float> [[I1]]) 116db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = fcmp ogt float [[X:%.*]], [[Y]] 117db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i1> poison, i1 [[R_SCALAR]], i64 1 118db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[R]] 119db7a2f34SJuneyoung Lee; 120db7a2f34SJuneyoung Lee %i0 = insertelement <4 x float> poison, float %x, i32 1 121db7a2f34SJuneyoung Lee %i1 = insertelement <4 x float> poison, float %y, i32 1 122db7a2f34SJuneyoung Lee call void @usef(<4 x float> %i1) 123db7a2f34SJuneyoung Lee %r = fcmp ogt <4 x float> %i0, %i1 124db7a2f34SJuneyoung Lee ret <4 x i1> %r 125db7a2f34SJuneyoung Lee} 126db7a2f34SJuneyoung Lee 127db7a2f34SJuneyoung Lee; If the scalar cmp is not cheaper than the vector cmp, extra uses can prevent the transform. 128db7a2f34SJuneyoung Lee 129db7a2f34SJuneyoung Leedefine <4 x i1> @ins2_ins2_f32_uses(float %x, float %y) { 130db7a2f34SJuneyoung Lee; CHECK-LABEL: @ins2_ins2_f32_uses( 131db7a2f34SJuneyoung Lee; CHECK-NEXT: [[I0:%.*]] = insertelement <4 x float> poison, float [[X:%.*]], i32 2 132db7a2f34SJuneyoung Lee; CHECK-NEXT: call void @usef(<4 x float> [[I0]]) 133db7a2f34SJuneyoung Lee; CHECK-NEXT: [[I1:%.*]] = insertelement <4 x float> poison, float [[Y:%.*]], i32 2 134db7a2f34SJuneyoung Lee; CHECK-NEXT: call void @usef(<4 x float> [[I1]]) 1350dcd2b40SSimon Pilgrim; CHECK-NEXT: [[R:%.*]] = fcmp oeq <4 x float> [[I0]], [[I1]] 136db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[R]] 137db7a2f34SJuneyoung Lee; 138db7a2f34SJuneyoung Lee %i0 = insertelement <4 x float> poison, float %x, i32 2 139db7a2f34SJuneyoung Lee call void @usef(<4 x float> %i0) 140db7a2f34SJuneyoung Lee %i1 = insertelement <4 x float> poison, float %y, i32 2 141db7a2f34SJuneyoung Lee call void @usef(<4 x float> %i1) 142db7a2f34SJuneyoung Lee %r = fcmp oeq <4 x float> %i0, %i1 143db7a2f34SJuneyoung Lee ret <4 x i1> %r 144db7a2f34SJuneyoung Lee} 145db7a2f34SJuneyoung Lee 146db7a2f34SJuneyoung Leedefine <2 x i1> @constant_op1_i64(i64 %x) { 147db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op1_i64( 148db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp ne i64 [[X:%.*]], 42 149db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i1> poison, i1 [[R_SCALAR]], i64 0 150db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 151db7a2f34SJuneyoung Lee; 152db7a2f34SJuneyoung Lee %ins = insertelement <2 x i64> poison, i64 %x, i32 0 153db7a2f34SJuneyoung Lee %r = icmp ne <2 x i64> %ins, <i64 42, i64 undef> 154db7a2f34SJuneyoung Lee ret <2 x i1> %r 155db7a2f34SJuneyoung Lee} 156db7a2f34SJuneyoung Lee 157db7a2f34SJuneyoung Leedefine <2 x i1> @constant_op1_i64_not_undef_lane(i64 %x) { 158db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op1_i64_not_undef_lane( 159db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp sge i64 [[X:%.*]], 42 160db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i1> poison, i1 [[R_SCALAR]], i64 0 161db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 162db7a2f34SJuneyoung Lee; 163db7a2f34SJuneyoung Lee %ins = insertelement <2 x i64> poison, i64 %x, i32 0 164db7a2f34SJuneyoung Lee %r = icmp sge <2 x i64> %ins, <i64 42, i64 -42> 165db7a2f34SJuneyoung Lee ret <2 x i1> %r 166db7a2f34SJuneyoung Lee} 167db7a2f34SJuneyoung Lee 168db7a2f34SJuneyoung Lee; negative test - load prevents the transform 169db7a2f34SJuneyoung Lee 170c00ffbe0SNikita Popovdefine <2 x i1> @constant_op1_i64_load(ptr %p) { 171db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op1_i64_load( 172*e39f6c18SAlex Richardson; CHECK-NEXT: [[LD:%.*]] = load i64, ptr [[P:%.*]], align 8 173db7a2f34SJuneyoung Lee; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> poison, i64 [[LD]], i32 0 174db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i64> [[INS]], <i64 42, i64 -42> 175db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 176db7a2f34SJuneyoung Lee; 177c00ffbe0SNikita Popov %ld = load i64, ptr %p 178db7a2f34SJuneyoung Lee %ins = insertelement <2 x i64> poison, i64 %ld, i32 0 179db7a2f34SJuneyoung Lee %r = icmp eq <2 x i64> %ins, <i64 42, i64 -42> 180db7a2f34SJuneyoung Lee ret <2 x i1> %r 181db7a2f34SJuneyoung Lee} 182db7a2f34SJuneyoung Lee 183db7a2f34SJuneyoung Leedefine <4 x i1> @constant_op0_i32(i32 %x) { 184db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op0_i32( 185db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp ult i32 -42, [[X:%.*]] 186db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i1> poison, i1 [[R_SCALAR]], i64 1 187db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[R]] 188db7a2f34SJuneyoung Lee; 189db7a2f34SJuneyoung Lee %ins = insertelement <4 x i32> poison, i32 %x, i32 1 190db7a2f34SJuneyoung Lee %r = icmp ult <4 x i32> <i32 undef, i32 -42, i32 undef, i32 undef>, %ins 191db7a2f34SJuneyoung Lee ret <4 x i1> %r 192db7a2f34SJuneyoung Lee} 193db7a2f34SJuneyoung Lee 194db7a2f34SJuneyoung Leedefine <4 x i1> @constant_op0_i32_not_undef_lane(i32 %x) { 195db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op0_i32_not_undef_lane( 196db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = icmp ule i32 42, [[X:%.*]] 197db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i1> poison, i1 [[R_SCALAR]], i64 1 198db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[R]] 199db7a2f34SJuneyoung Lee; 200db7a2f34SJuneyoung Lee %ins = insertelement <4 x i32> poison, i32 %x, i32 1 201db7a2f34SJuneyoung Lee %r = icmp ule <4 x i32> <i32 1, i32 42, i32 42, i32 -42>, %ins 202db7a2f34SJuneyoung Lee ret <4 x i1> %r 203db7a2f34SJuneyoung Lee} 204db7a2f34SJuneyoung Lee 205db7a2f34SJuneyoung Leedefine <2 x i1> @constant_op0_f64(double %x) { 206db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op0_f64( 207db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = fcmp fast olt double 4.200000e+01, [[X:%.*]] 208db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i1> poison, i1 [[R_SCALAR]], i64 0 209db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 210db7a2f34SJuneyoung Lee; 211db7a2f34SJuneyoung Lee %ins = insertelement <2 x double> poison, double %x, i32 0 212db7a2f34SJuneyoung Lee %r = fcmp fast olt <2 x double> <double 42.0, double undef>, %ins 213db7a2f34SJuneyoung Lee ret <2 x i1> %r 214db7a2f34SJuneyoung Lee} 215db7a2f34SJuneyoung Lee 216db7a2f34SJuneyoung Leedefine <2 x i1> @constant_op0_f64_not_undef_lane(double %x) { 217db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op0_f64_not_undef_lane( 218db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = fcmp nnan ueq double -4.200000e+01, [[X:%.*]] 219db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i1> poison, i1 [[R_SCALAR]], i64 1 220db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 221db7a2f34SJuneyoung Lee; 222db7a2f34SJuneyoung Lee %ins = insertelement <2 x double> poison, double %x, i32 1 223db7a2f34SJuneyoung Lee %r = fcmp nnan ueq <2 x double> <double 42.0, double -42.0>, %ins 224db7a2f34SJuneyoung Lee ret <2 x i1> %r 225db7a2f34SJuneyoung Lee} 226db7a2f34SJuneyoung Lee 227db7a2f34SJuneyoung Leedefine <2 x i1> @constant_op1_f64(double %x) { 228db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op1_f64( 229db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = fcmp one double [[X:%.*]], 4.200000e+01 230db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <2 x i1> poison, i1 [[R_SCALAR]], i64 1 231db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <2 x i1> [[R]] 232db7a2f34SJuneyoung Lee; 233db7a2f34SJuneyoung Lee %ins = insertelement <2 x double> poison, double %x, i32 1 234db7a2f34SJuneyoung Lee %r = fcmp one <2 x double> %ins, <double undef, double 42.0> 235db7a2f34SJuneyoung Lee ret <2 x i1> %r 236db7a2f34SJuneyoung Lee} 237db7a2f34SJuneyoung Lee 238db7a2f34SJuneyoung Leedefine <4 x i1> @constant_op1_f32_not_undef_lane(float %x) { 239db7a2f34SJuneyoung Lee; CHECK-LABEL: @constant_op1_f32_not_undef_lane( 240db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R_SCALAR:%.*]] = fcmp uge float [[X:%.*]], 4.200000e+01 241db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i1> poison, i1 [[R_SCALAR]], i64 0 242db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[R]] 243db7a2f34SJuneyoung Lee; 244db7a2f34SJuneyoung Lee %ins = insertelement <4 x float> poison, float %x, i32 0 245db7a2f34SJuneyoung Lee %r = fcmp uge <4 x float> %ins, <float 42.0, float -42.0, float 0.0, float 1.0> 246db7a2f34SJuneyoung Lee ret <4 x i1> %r 247db7a2f34SJuneyoung Lee} 248db7a2f34SJuneyoung Lee 249db7a2f34SJuneyoung Lee; negative test - select prevents the transform 250db7a2f34SJuneyoung Lee 251db7a2f34SJuneyoung Leedefine <4 x float> @vec_select_use1(<4 x float> %x, <4 x float> %y, i32 %a, i32 %b) { 252db7a2f34SJuneyoung Lee; CHECK-LABEL: @vec_select_use1( 253db7a2f34SJuneyoung Lee; CHECK-NEXT: [[VECA:%.*]] = insertelement <4 x i32> poison, i32 [[A:%.*]], i8 0 254db7a2f34SJuneyoung Lee; CHECK-NEXT: [[VECB:%.*]] = insertelement <4 x i32> poison, i32 [[B:%.*]], i8 0 255db7a2f34SJuneyoung Lee; CHECK-NEXT: [[COND:%.*]] = icmp eq <4 x i32> [[VECA]], [[VECB]] 256db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = select <4 x i1> [[COND]], <4 x float> [[X:%.*]], <4 x float> [[Y:%.*]] 257db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x float> [[R]] 258db7a2f34SJuneyoung Lee; 259db7a2f34SJuneyoung Lee %veca = insertelement <4 x i32> poison, i32 %a, i8 0 260db7a2f34SJuneyoung Lee %vecb = insertelement <4 x i32> poison, i32 %b, i8 0 261db7a2f34SJuneyoung Lee %cond = icmp eq <4 x i32> %veca, %vecb 262db7a2f34SJuneyoung Lee %r = select <4 x i1> %cond, <4 x float> %x, <4 x float> %y 263db7a2f34SJuneyoung Lee ret <4 x float> %r 264db7a2f34SJuneyoung Lee} 265db7a2f34SJuneyoung Lee 266db7a2f34SJuneyoung Lee; negative test - select prevents the transform 267db7a2f34SJuneyoung Lee 268db7a2f34SJuneyoung Leedefine <4 x float> @vec_select_use2(<4 x float> %x, <4 x float> %y, float %a) { 269db7a2f34SJuneyoung Lee; CHECK-LABEL: @vec_select_use2( 270db7a2f34SJuneyoung Lee; CHECK-NEXT: [[VECA:%.*]] = insertelement <4 x float> poison, float [[A:%.*]], i8 0 271db7a2f34SJuneyoung Lee; CHECK-NEXT: [[COND:%.*]] = fcmp oeq <4 x float> [[VECA]], zeroinitializer 272db7a2f34SJuneyoung Lee; CHECK-NEXT: [[R:%.*]] = select <4 x i1> [[COND]], <4 x float> [[X:%.*]], <4 x float> [[Y:%.*]] 273db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x float> [[R]] 274db7a2f34SJuneyoung Lee; 275db7a2f34SJuneyoung Lee %veca = insertelement <4 x float> poison, float %a, i8 0 276db7a2f34SJuneyoung Lee %cond = fcmp oeq <4 x float> %veca, zeroinitializer 277db7a2f34SJuneyoung Lee %r = select <4 x i1> %cond, <4 x float> %x, <4 x float> %y 278db7a2f34SJuneyoung Lee ret <4 x float> %r 279db7a2f34SJuneyoung Lee} 280db7a2f34SJuneyoung Lee 281c00ffbe0SNikita Popovdefine <4 x i1> @vector_of_pointers(ptr %t1) { 282db7a2f34SJuneyoung Lee; CHECK-LABEL: @vector_of_pointers( 283c00ffbe0SNikita Popov; CHECK-NEXT: [[T6_SCALAR:%.*]] = icmp ne ptr [[T1:%.*]], null 284db7a2f34SJuneyoung Lee; CHECK-NEXT: [[T6:%.*]] = insertelement <4 x i1> poison, i1 [[T6_SCALAR]], i64 0 285db7a2f34SJuneyoung Lee; CHECK-NEXT: ret <4 x i1> [[T6]] 286db7a2f34SJuneyoung Lee; 287c00ffbe0SNikita Popov %t5 = insertelement <4 x ptr> poison, ptr %t1, i32 0 288c00ffbe0SNikita Popov %t6 = icmp ne <4 x ptr> %t5, zeroinitializer 289db7a2f34SJuneyoung Lee ret <4 x i1> %t6 290db7a2f34SJuneyoung Lee} 291