1*76875480SMatthias Braun; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 2*76875480SMatthias Braun; RUN: opt < %s -S -passes=instcombine | FileCheck %s 3*76875480SMatthias Braun 4*76875480SMatthias Braundefine <4 x i16> @f0(i1 %c, ptr %p0, ptr %p1) { 5*76875480SMatthias Braun; CHECK-LABEL: define <4 x i16> @f0( 6*76875480SMatthias Braun; CHECK-SAME: i1 [[C:%.*]], ptr [[P0:%.*]], ptr [[P1:%.*]]) { 7*76875480SMatthias Braun; CHECK-NEXT: [[ENTRY:.*]]: 8*76875480SMatthias Braun; CHECK-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[MERGE:.*]] 9*76875480SMatthias Braun; CHECK: [[THEN]]: 10*76875480SMatthias Braun; CHECK-NEXT: [[LOAD0:%.*]] = load <4 x i16>, ptr [[P0]], align 16 11*76875480SMatthias Braun; CHECK-NEXT: [[LOAD1:%.*]] = load <4 x i16>, ptr [[P1]], align 16 12*76875480SMatthias Braun; CHECK-NEXT: [[TMP0:%.*]] = sub <4 x i16> [[LOAD0]], [[LOAD1]] 13*76875480SMatthias Braun; CHECK-NEXT: br label %[[MERGE]] 14*76875480SMatthias Braun; CHECK: [[MERGE]]: 15*76875480SMatthias Braun; CHECK-NEXT: [[SUB:%.*]] = phi <4 x i16> [ <i16 -87, i16 327, i16 51, i16 755>, %[[ENTRY]] ], [ [[TMP0]], %[[THEN]] ] 16*76875480SMatthias Braun; CHECK-NEXT: ret <4 x i16> [[SUB]] 17*76875480SMatthias Braun; 18*76875480SMatthias Braunentry: 19*76875480SMatthias Braun br i1 %c, label %then, label %merge 20*76875480SMatthias Braun 21*76875480SMatthias Braunthen: 22*76875480SMatthias Braun %load0 = load <4 x i16>, ptr %p0, align 16 23*76875480SMatthias Braun %load1 = load <4 x i16>, ptr %p1, align 16 24*76875480SMatthias Braun %interleave = shufflevector <4 x i16> %load0, <4 x i16> %load1, <8 x i32> <i32 0, i32 7, i32 1, i32 6, i32 2, i32 5, i32 3, i32 4> 25*76875480SMatthias Braun br label %merge 26*76875480SMatthias Braun 27*76875480SMatthias Braunmerge: 28*76875480SMatthias Braun %phi = phi <8 x i16> [<i16 1, i16 22, i16 333, i16 4, i16 55, i16 6, i16 777, i16 88>, %entry], [%interleave, %then] 29*76875480SMatthias Braun %shuf0 = shufflevector <8 x i16> %phi, <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6> 30*76875480SMatthias Braun %shuf1 = shufflevector <8 x i16> %phi, <8 x i16> poison, <4 x i32> <i32 7, i32 5, i32 3, i32 1> 31*76875480SMatthias Braun %sub = sub <4 x i16> %shuf0, %shuf1 32*76875480SMatthias Braun ret <4 x i16> %sub 33*76875480SMatthias Braun} 34*76875480SMatthias Braun 35*76875480SMatthias Braundefine void @deinterleave_interleave(ptr %p_begin, ptr %p_end, ptr %out) { 36*76875480SMatthias Braun; CHECK-LABEL: define void @deinterleave_interleave( 37*76875480SMatthias Braun; CHECK-SAME: ptr [[P_BEGIN:%.*]], ptr [[P_END:%.*]], ptr [[OUT:%.*]]) { 38*76875480SMatthias Braun; CHECK-NEXT: [[ENTRY:.*]]: 39*76875480SMatthias Braun; CHECK-NEXT: br label %[[LOOP:.*]] 40*76875480SMatthias Braun; CHECK: [[LOOP]]: 41*76875480SMatthias Braun; CHECK-NEXT: [[ACC:%.*]] = phi <4 x float> [ zeroinitializer, %[[ENTRY]] ], [ [[SUM_LOWS:%.*]], %[[LOOP]] ] 42*76875480SMatthias Braun; CHECK-NEXT: [[ODDS:%.*]] = phi <4 x float> [ zeroinitializer, %[[ENTRY]] ], [ [[SUM_HIGHS:%.*]], %[[LOOP]] ] 43*76875480SMatthias Braun; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[P_BEGIN]], %[[ENTRY]] ], [ [[P_INC:%.*]], %[[LOOP]] ] 44*76875480SMatthias Braun; CHECK-NEXT: [[VAL:%.*]] = load <4 x i8>, ptr [[P]], align 4 45*76875480SMatthias Braun; CHECK-NEXT: [[HIGHS:%.*]] = ashr <4 x i8> [[VAL]], splat (i8 4) 46*76875480SMatthias Braun; CHECK-NEXT: [[LOWS:%.*]] = and <4 x i8> [[VAL]], splat (i8 15) 47*76875480SMatthias Braun; CHECK-NEXT: [[HIGHS_F:%.*]] = sitofp <4 x i8> [[HIGHS]] to <4 x float> 48*76875480SMatthias Braun; CHECK-NEXT: [[LOWS_F:%.*]] = uitofp nneg <4 x i8> [[LOWS]] to <4 x float> 49*76875480SMatthias Braun; CHECK-NEXT: [[SUM_LOWS]] = fadd <4 x float> [[ACC]], [[LOWS_F]] 50*76875480SMatthias Braun; CHECK-NEXT: [[SUM_HIGHS]] = fadd <4 x float> [[ODDS]], [[HIGHS_F]] 51*76875480SMatthias Braun; CHECK-NEXT: [[P_INC]] = getelementptr inbounds nuw i8, ptr [[P]], i64 4 52*76875480SMatthias Braun; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[P_INC]], [[P_END]] 53*76875480SMatthias Braun; CHECK-NEXT: br i1 [[C]], label %[[EXIT:.*]], label %[[LOOP]] 54*76875480SMatthias Braun; CHECK: [[EXIT]]: 55*76875480SMatthias Braun; CHECK-NEXT: [[INTERLEAVE:%.*]] = shufflevector <4 x float> [[SUM_LOWS]], <4 x float> [[SUM_HIGHS]], <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 56*76875480SMatthias Braun; CHECK-NEXT: store <8 x float> [[INTERLEAVE]], ptr [[OUT]], align 4 57*76875480SMatthias Braun; CHECK-NEXT: ret void 58*76875480SMatthias Braun; 59*76875480SMatthias Braunentry: 60*76875480SMatthias Braun br label %loop 61*76875480SMatthias Braun 62*76875480SMatthias Braunloop: 63*76875480SMatthias Braun %acc = phi <8 x float> [ zeroinitializer, %entry ], [ %interleave, %loop ] 64*76875480SMatthias Braun %p = phi ptr [%p_begin, %entry ], [%p_inc, %loop] 65*76875480SMatthias Braun 66*76875480SMatthias Braun %evens = shufflevector <8 x float> %acc, <8 x float> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6> 67*76875480SMatthias Braun %odds = shufflevector <8 x float> %acc, <8 x float> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7> 68*76875480SMatthias Braun 69*76875480SMatthias Braun %val = load <4 x i8>, ptr %p, align 4 70*76875480SMatthias Braun %highs = ashr <4 x i8> %val, <i8 4, i8 4, i8 4, i8 4> 71*76875480SMatthias Braun %lows = and <4 x i8> %val, <i8 15, i8 15, i8 15, i8 15> 72*76875480SMatthias Braun 73*76875480SMatthias Braun %highs_f = sitofp <4 x i8> %highs to <4 x float> 74*76875480SMatthias Braun %lows_f = sitofp <4 x i8> %lows to <4 x float> 75*76875480SMatthias Braun 76*76875480SMatthias Braun %sum_lows = fadd <4 x float> %evens, %lows_f 77*76875480SMatthias Braun %sum_highs = fadd <4 x float> %odds, %highs_f 78*76875480SMatthias Braun 79*76875480SMatthias Braun %interleave = shufflevector <4 x float> %sum_lows, <4 x float> %sum_highs, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7> 80*76875480SMatthias Braun 81*76875480SMatthias Braun %p_inc = getelementptr inbounds i8, ptr %p, i32 4 82*76875480SMatthias Braun %c = icmp eq ptr %p_inc, %p_end 83*76875480SMatthias Braun br i1 %c, label %exit, label %loop 84*76875480SMatthias Braun 85*76875480SMatthias Braunexit: 86*76875480SMatthias Braun store <8 x float> %interleave, ptr %out, align 4 87*76875480SMatthias Braun ret void 88*76875480SMatthias Braun} 89*76875480SMatthias Braun 90*76875480SMatthias Braundefine <4 x i16> @f1(i1 %c, ptr %p) { 91*76875480SMatthias Braun; CHECK-LABEL: define <4 x i16> @f1( 92*76875480SMatthias Braun; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) { 93*76875480SMatthias Braun; CHECK-NEXT: [[ENTRY:.*]]: 94*76875480SMatthias Braun; CHECK-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[MERGE:.*]] 95*76875480SMatthias Braun; CHECK: [[THEN]]: 96*76875480SMatthias Braun; CHECK-NEXT: store i32 42, ptr [[P]], align 4 97*76875480SMatthias Braun; CHECK-NEXT: br label %[[MERGE]] 98*76875480SMatthias Braun; CHECK: [[MERGE]]: 99*76875480SMatthias Braun; CHECK-NEXT: [[XOR:%.*]] = phi <4 x i16> [ <i16 3, i16 346, i16 undef, i16 undef>, %[[ENTRY]] ], [ <i16 7, i16 74, i16 undef, i16 undef>, %[[THEN]] ] 100*76875480SMatthias Braun; CHECK-NEXT: ret <4 x i16> [[XOR]] 101*76875480SMatthias Braun; 102*76875480SMatthias Braunentry: 103*76875480SMatthias Braun br i1 %c, label %then, label %merge 104*76875480SMatthias Braun 105*76875480SMatthias Braunthen: 106*76875480SMatthias Braun store i32 42, ptr %p, align 4 107*76875480SMatthias Braun br label %merge 108*76875480SMatthias Braun 109*76875480SMatthias Braunmerge: 110*76875480SMatthias Braun %phi = phi <4 x i16> [<i16 1, i16 22, i16 333, i16 4>, %entry], [<i16 555, i16 6, i16 77, i16 8>, %then] 111*76875480SMatthias Braun %shuf0 = shufflevector <4 x i16> %phi, <4 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6> 112*76875480SMatthias Braun %add1 = add <4 x i16> %phi, <i16 1, i16 1, i16 1, i16 1> 113*76875480SMatthias Braun %xor = xor <4 x i16> %shuf0, %add1 114*76875480SMatthias Braun ret <4 x i16> %xor 115*76875480SMatthias Braun} 116