1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -passes=loop-vectorize -force-vector-width=2 -S %s | FileCheck %s 3 4@src = external global [32 x i16], align 1 5@dst = external global [32 x i16], align 1 6 7; The load in the loop does not need predication, because the accessed memory 8; is de-referenceable for all loop iterations. 9define void @single_incoming_phi_no_blend_mask(i64 %a, i64 %b) { 10; CHECK-LABEL: @single_incoming_phi_no_blend_mask( 11; CHECK-NEXT: entry: 12; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 13; CHECK: vector.ph: 14; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i64> poison, i64 [[A:%.*]], i32 0 15; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT]], <2 x i64> poison, <2 x i32> zeroinitializer 16; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 17; CHECK: vector.body: 18; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 19; CHECK-NEXT: [[VEC_IND:%.*]] = phi <2 x i64> [ <i64 0, i64 1>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ] 20; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[INDEX]] to i16 21; CHECK-NEXT: [[TMP3:%.*]] = add i16 [[TMP2]], 0 22; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0 23; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 [[TMP3]] 24; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i16, i16* [[TMP4]], i32 0 25; CHECK-NEXT: [[TMP6:%.*]] = bitcast i16* [[TMP5]] to <2 x i16>* 26; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i16>, <2 x i16>* [[TMP6]], align 1 27; CHECK-NEXT: [[TMP7:%.*]] = icmp sgt <2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]] 28; CHECK-NEXT: [[TMP8:%.*]] = xor <2 x i1> [[TMP7]], <i1 true, i1 true> 29; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP7]], <2 x i16> <i16 1, i16 1>, <2 x i16> [[WIDE_LOAD]] 30; CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @dst, i16 0, i64 [[TMP0]] 31; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds i16, i16* [[TMP9]], i32 0 32; CHECK-NEXT: [[TMP11:%.*]] = bitcast i16* [[TMP10]] to <2 x i16>* 33; CHECK-NEXT: store <2 x i16> [[PREDPHI]], <2 x i16>* [[TMP11]], align 2 34; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2 35; CHECK-NEXT: [[VEC_IND_NEXT]] = add <2 x i64> [[VEC_IND]], <i64 2, i64 2> 36; CHECK-NEXT: [[TMP12:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32 37; CHECK-NEXT: br i1 [[TMP12]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]] 38; CHECK: middle.block: 39; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 32, 32 40; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]] 41; 42entry: 43 br label %loop.header 44 45loop.header: 46 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ] 47 %iv.trunc = trunc i64 %iv to i16 48 br label %loop.cond 49 50loop.cond: 51 %blend = phi i16 [ %iv.trunc, %loop.header ] 52 %src.ptr = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 %blend 53 %lv = load i16, i16* %src.ptr, align 1 54 %cmp.b = icmp sgt i64 %iv, %a 55 br i1 %cmp.b, label %loop.next, label %loop.latch 56 57loop.next: 58 br label %loop.latch 59 60loop.latch: 61 %res = phi i16 [ %lv, %loop.cond ], [ 1, %loop.next ] 62 %dst.ptr = getelementptr inbounds [32 x i16], [32 x i16]* @dst, i16 0, i64 %iv 63 store i16 %res, i16* %dst.ptr 64 %iv.next = add nuw nsw i64 %iv, 1 65 %cmp439 = icmp ult i64 %iv, 31 66 br i1 %cmp439, label %loop.header, label %exit 67 68exit: 69 ret void 70} 71 72; The load in the loop does not need predication, because the accessed memory 73; is de-referenceable for all loop iterations. 74define void @single_incoming_phi_with_blend_mask(i64 %a, i64 %b) { 75; CHECK-LABEL: @single_incoming_phi_with_blend_mask( 76; CHECK-NEXT: entry: 77; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 78; CHECK: vector.ph: 79; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i64> poison, i64 [[A:%.*]], i32 0 80; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT]], <2 x i64> poison, <2 x i32> zeroinitializer 81; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 82; CHECK: vector.body: 83; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 84; CHECK-NEXT: [[VEC_IND:%.*]] = phi <2 x i64> [ <i64 0, i64 1>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ] 85; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[INDEX]] to i16 86; CHECK-NEXT: [[TMP3:%.*]] = add i16 [[TMP2]], 0 87; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0 88; CHECK-NEXT: [[TMP4:%.*]] = icmp ugt <2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]] 89; CHECK-NEXT: [[TMP5:%.*]] = getelementptr [32 x i16], [32 x i16]* @src, i16 0, i16 [[TMP3]] 90; CHECK-NEXT: [[TMP6:%.*]] = getelementptr i16, i16* [[TMP5]], i32 0 91; CHECK-NEXT: [[TMP7:%.*]] = bitcast i16* [[TMP6]] to <2 x i16>* 92; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i16>, <2 x i16>* [[TMP7]], align 1 93; CHECK-NEXT: [[TMP8:%.*]] = icmp sgt <2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]] 94; CHECK-NEXT: [[TMP9:%.*]] = xor <2 x i1> [[TMP4]], <i1 true, i1 true> 95; CHECK-NEXT: [[TMP10:%.*]] = xor <2 x i1> [[TMP8]], <i1 true, i1 true> 96; CHECK-NEXT: [[TMP11:%.*]] = select <2 x i1> [[TMP4]], <2 x i1> [[TMP10]], <2 x i1> zeroinitializer 97; CHECK-NEXT: [[TMP12:%.*]] = select <2 x i1> [[TMP4]], <2 x i1> [[TMP8]], <2 x i1> zeroinitializer 98; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP11]], <2 x i16> [[WIDE_LOAD]], <2 x i16> zeroinitializer 99; CHECK-NEXT: [[PREDPHI1:%.*]] = select <2 x i1> [[TMP12]], <2 x i16> <i16 1, i16 1>, <2 x i16> [[PREDPHI]] 100; CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @dst, i16 0, i64 [[TMP0]] 101; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i16, i16* [[TMP13]], i32 0 102; CHECK-NEXT: [[TMP15:%.*]] = bitcast i16* [[TMP14]] to <2 x i16>* 103; CHECK-NEXT: store <2 x i16> [[PREDPHI1]], <2 x i16>* [[TMP15]], align 2 104; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2 105; CHECK-NEXT: [[VEC_IND_NEXT]] = add <2 x i64> [[VEC_IND]], <i64 2, i64 2> 106; CHECK-NEXT: [[TMP16:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32 107; CHECK-NEXT: br i1 [[TMP16]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP4:!llvm.loop !.*]] 108; CHECK: middle.block: 109; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 32, 32 110; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]] 111; 112entry: 113 br label %loop.header 114 115loop.header: 116 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ] 117 %iv.trunc = trunc i64 %iv to i16 118 %cmp.a = icmp ugt i64 %iv, %a 119 br i1 %cmp.a, label %loop.cond, label %loop.latch 120 121loop.cond: 122 %blend = phi i16 [ %iv.trunc, %loop.header ] 123 %src.ptr = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 %blend 124 %lv = load i16, i16* %src.ptr, align 1 125 %cmp.b = icmp sgt i64 %iv, %a 126 br i1 %cmp.b, label %loop.next, label %loop.latch 127 128loop.next: 129 br label %loop.latch 130 131loop.latch: 132 %res = phi i16 [ 0, %loop.header ], [ %lv, %loop.cond ], [ 1, %loop.next ] 133 %dst.ptr = getelementptr inbounds [32 x i16], [32 x i16]* @dst, i16 0, i64 %iv 134 store i16 %res, i16* %dst.ptr 135 %iv.next = add nuw nsw i64 %iv, 1 136 %cmp439 = icmp ult i64 %iv, 31 137 br i1 %cmp439, label %loop.header, label %exit 138 139exit: 140 ret void 141} 142 143define void @multiple_incoming_phi_with_blend_mask(i64 %a, i16* noalias %dst) { 144; CHECK-LABEL: @multiple_incoming_phi_with_blend_mask( 145; CHECK-NEXT: entry: 146; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 147; CHECK: vector.ph: 148; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i64> poison, i64 [[A:%.*]], i32 0 149; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT]], <2 x i64> poison, <2 x i32> zeroinitializer 150; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 151; CHECK: vector.body: 152; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 153; CHECK-NEXT: [[VEC_IND:%.*]] = phi <2 x i64> [ <i64 0, i64 1>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ] 154; CHECK-NEXT: [[VEC_IND1:%.*]] = phi <2 x i16> [ <i16 0, i16 1>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT2:%.*]], [[VECTOR_BODY]] ] 155; CHECK-NEXT: [[VEC_IND3:%.*]] = phi <2 x i16> [ <i16 0, i16 1>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT4:%.*]], [[VECTOR_BODY]] ] 156; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0 157; CHECK-NEXT: [[TMP2:%.*]] = icmp ugt <2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]] 158; CHECK-NEXT: [[TMP3:%.*]] = xor <2 x i1> [[TMP2]], <i1 true, i1 true> 159; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP2]], <2 x i16> [[VEC_IND3]], <2 x i16> [[VEC_IND1]] 160; CHECK-NEXT: [[TMP4:%.*]] = extractelement <2 x i16> [[PREDPHI]], i32 0 161; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 [[TMP4]] 162; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i16> [[PREDPHI]], i32 1 163; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 [[TMP6]] 164; CHECK-NEXT: [[TMP8:%.*]] = load i16, i16* [[TMP5]], align 1 165; CHECK-NEXT: [[TMP9:%.*]] = load i16, i16* [[TMP7]], align 1 166; CHECK-NEXT: [[INS1:%.+]] = insertelement <2 x i16> poison, i16 [[TMP8]], i32 0 167; CHECK-NEXT: [[INS2:%.+]] = insertelement <2 x i16> [[INS1]], i16 [[TMP9]], i32 1 168; CHECK-NEXT: [[DST0:%.+]] = getelementptr inbounds i16, i16* %dst, i64 [[TMP0]] 169; CHECK-NEXT: [[DST1:%.+]] = getelementptr inbounds i16, i16* [[DST0]], i32 0 170; CHECK-NEXT: [[DST1_BC:%.+]] = bitcast i16* [[DST1]] to <2 x i16>* 171; CHECK-NEXT: store <2 x i16> [[INS2]], <2 x i16>* [[DST1_BC]], align 2 172; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2 173; CHECK-NEXT: [[VEC_IND_NEXT]] = add <2 x i64> [[VEC_IND]], <i64 2, i64 2> 174; CHECK-NEXT: [[VEC_IND_NEXT2]] = add <2 x i16> [[VEC_IND1]], <i16 2, i16 2> 175; CHECK-NEXT: [[VEC_IND_NEXT4]] = add <2 x i16> [[VEC_IND3]], <i16 2, i16 2> 176; CHECK-NEXT: [[TMP10:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32 177; CHECK-NEXT: br i1 [[TMP10]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP6:!llvm.loop !.*]] 178; CHECK: middle.block: 179; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 32, 32 180; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]] 181; 182entry: 183 br label %loop.header 184 185loop.header: 186 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ] 187 %iv.trunc = trunc i64 %iv to i16 188 %iv.trunc.2 = trunc i64 %iv to i16 189 %cmp.a = icmp ugt i64 %iv, %a 190 br i1 %cmp.a, label %loop.next, label %loop.latch 191 192loop.next: 193 br label %loop.latch 194 195loop.latch: 196 %blend = phi i16 [ %iv.trunc, %loop.header ], [ %iv.trunc.2, %loop.next ] 197 %src.ptr = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 %blend 198 %lv = load i16, i16* %src.ptr, align 1 199 %dst.ptr = getelementptr inbounds i16, i16* %dst, i64 %iv 200 store i16 %lv, i16* %dst.ptr 201 %iv.next = add nuw nsw i64 %iv, 1 202 %cmp439 = icmp ult i64 %iv, 31 203 br i1 %cmp439, label %loop.header, label %exit 204 205exit: 206 ret void 207} 208 209; The load in the loop needs predication, because the accessed memory is not 210; de-referencable for all iterations of the loop. 211define void @single_incoming_needs_predication(i64 %a, i64 %b) { 212; CHECK-LABEL: @single_incoming_needs_predication( 213; CHECK-NEXT: entry: 214; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 215; CHECK: vector.ph: 216; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i64> poison, i64 [[A:%.*]], i32 0 217; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT]], <2 x i64> poison, <2 x i32> zeroinitializer 218; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 219; CHECK: vector.body: 220; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_LOAD_CONTINUE2:%.*]] ] 221; CHECK-NEXT: [[VEC_IND:%.*]] = phi <2 x i64> [ <i64 0, i64 1>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[PRED_LOAD_CONTINUE2]] ] 222; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[INDEX]] to i16 223; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[INDEX]], 0 224; CHECK-NEXT: [[TMP2:%.*]] = icmp ugt <2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]] 225; CHECK-NEXT: [[TMP3:%.*]] = extractelement <2 x i1> [[TMP2]], i32 0 226; CHECK-NEXT: br i1 [[TMP3]], label [[PRED_LOAD_IF:%.*]], label [[PRED_LOAD_CONTINUE:%.*]] 227; CHECK: pred.load.if: 228; CHECK-NEXT: [[TMP4:%.*]] = add i16 [[TMP0]], 0 229; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 [[TMP4]] 230; CHECK-NEXT: [[TMP6:%.*]] = load i16, i16* [[TMP5]], align 1 231; CHECK-NEXT: [[TMP7:%.*]] = insertelement <2 x i16> poison, i16 [[TMP6]], i32 0 232; CHECK-NEXT: br label [[PRED_LOAD_CONTINUE]] 233; CHECK: pred.load.continue: 234; CHECK-NEXT: [[TMP8:%.*]] = phi <2 x i16> [ poison, [[VECTOR_BODY]] ], [ [[TMP7]], [[PRED_LOAD_IF]] ] 235; CHECK-NEXT: [[TMP9:%.*]] = extractelement <2 x i1> [[TMP2]], i32 1 236; CHECK-NEXT: br i1 [[TMP9]], label [[PRED_LOAD_IF1:%.*]], label [[PRED_LOAD_CONTINUE2]] 237; CHECK: pred.load.if1: 238; CHECK-NEXT: [[TMP10:%.*]] = add i16 [[TMP0]], 1 239; CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 [[TMP10]] 240; CHECK-NEXT: [[TMP12:%.*]] = load i16, i16* [[TMP11]], align 1 241; CHECK-NEXT: [[TMP13:%.*]] = insertelement <2 x i16> [[TMP8]], i16 [[TMP12]], i32 1 242; CHECK-NEXT: br label [[PRED_LOAD_CONTINUE2]] 243; CHECK: pred.load.continue2: 244; CHECK-NEXT: [[TMP14:%.*]] = phi <2 x i16> [ [[TMP8]], [[PRED_LOAD_CONTINUE]] ], [ [[TMP13]], [[PRED_LOAD_IF1]] ] 245; CHECK-NEXT: [[TMP15:%.*]] = icmp sgt <2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]] 246; CHECK-NEXT: [[TMP16:%.*]] = xor <2 x i1> [[TMP2]], <i1 true, i1 true> 247; CHECK-NEXT: [[TMP17:%.*]] = xor <2 x i1> [[TMP15]], <i1 true, i1 true> 248; CHECK-NEXT: [[TMP18:%.*]] = select <2 x i1> [[TMP2]], <2 x i1> [[TMP17]], <2 x i1> zeroinitializer 249; CHECK-NEXT: [[TMP19:%.*]] = select <2 x i1> [[TMP2]], <2 x i1> [[TMP15]], <2 x i1> zeroinitializer 250; CHECK-NEXT: [[PREDPHI:%.*]] = select <2 x i1> [[TMP18]], <2 x i16> [[TMP14]], <2 x i16> zeroinitializer 251; CHECK-NEXT: [[PREDPHI3:%.*]] = select <2 x i1> [[TMP19]], <2 x i16> <i16 1, i16 1>, <2 x i16> [[PREDPHI]] 252; CHECK-NEXT: [[TMP20:%.*]] = getelementptr inbounds [32 x i16], [32 x i16]* @dst, i16 0, i64 [[TMP1]] 253; CHECK-NEXT: [[TMP21:%.*]] = getelementptr inbounds i16, i16* [[TMP20]], i32 0 254; CHECK-NEXT: [[TMP22:%.*]] = bitcast i16* [[TMP21]] to <2 x i16>* 255; CHECK-NEXT: store <2 x i16> [[PREDPHI3]], <2 x i16>* [[TMP22]], align 2 256; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2 257; CHECK-NEXT: [[VEC_IND_NEXT]] = add <2 x i64> [[VEC_IND]], <i64 2, i64 2> 258; CHECK-NEXT: [[TMP23:%.*]] = icmp eq i64 [[INDEX_NEXT]], 64 259; CHECK-NEXT: br i1 [[TMP23]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]] 260; CHECK: middle.block: 261; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 64, 64 262; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]] 263; 264entry: 265 br label %loop.header 266 267loop.header: 268 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ] 269 %iv.trunc = trunc i64 %iv to i16 270 %cmp.a = icmp ugt i64 %iv, %a 271 br i1 %cmp.a, label %loop.cond, label %loop.latch 272 273loop.cond: 274 %blend = phi i16 [ %iv.trunc, %loop.header ] 275 %src.ptr = getelementptr inbounds [32 x i16], [32 x i16]* @src, i16 0, i16 %blend 276 %lv = load i16, i16* %src.ptr, align 1 277 %cmp.b = icmp sgt i64 %iv, %a 278 br i1 %cmp.b, label %loop.next, label %loop.latch 279 280loop.next: 281 br label %loop.latch 282 283loop.latch: 284 %res = phi i16 [ 0, %loop.header ], [ %lv, %loop.cond ], [ 1, %loop.next ] 285 %dst.ptr = getelementptr inbounds [32 x i16], [32 x i16]* @dst, i16 0, i64 %iv 286 store i16 %res, i16* %dst.ptr 287 %iv.next = add nuw nsw i64 %iv, 1 288 %cmp439 = icmp ult i64 %iv, 63 289 br i1 %cmp439, label %loop.header, label %exit 290 291exit: 292 ret void 293} 294 295; Test case for PR44800. 296define void @duplicated_incoming_blocks_blend(i32 %x, i32* %ptr) { 297; CHECK-LABEL: @duplicated_incoming_blocks_blend( 298; CHECK-NEXT: entry: 299; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 300; CHECK: vector.ph: 301; CHECK-NEXT: br label [[VECTOR_BODY:%.*]] 302; CHECK: vector.body: 303; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] 304; CHECK-NEXT: [[VEC_IND:%.*]] = phi <2 x i32> [ <i32 0, i32 1>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ] 305; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[INDEX]], 0 306; CHECK-NEXT: [[TMP1:%.*]] = getelementptr i32, i32* [[PTR:%.*]], i32 [[TMP0]] 307; CHECK-NEXT: [[TMP2:%.*]] = getelementptr i32, i32* [[TMP1]], i32 0 308; CHECK-NEXT: [[TMP3:%.*]] = bitcast i32* [[TMP2]] to <2 x i32>* 309; CHECK-NEXT: store <2 x i32> [[VEC_IND]], <2 x i32>* [[TMP3]], align 4 310; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2 311; CHECK-NEXT: [[VEC_IND_NEXT]] = add <2 x i32> [[VEC_IND]], <i32 2, i32 2> 312; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i32 [[INDEX_NEXT]], 1000 313; CHECK-NEXT: br i1 [[TMP4]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP10:![0-9]+]] 314; CHECK: middle.block: 315; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i32 1000, 1000 316; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]] 317; 318entry: 319 br label %loop.header 320 321loop.header: 322 %iv = phi i32 [ 0 , %entry ], [ %add.i, %loop.latch ] 323 %c.0 = icmp ugt i32 %iv, %x 324 br i1 %c.0, label %loop.latch, label %loop.latch 325 326loop.latch: 327 %p = phi i32 [ %iv, %loop.header ], [ %iv, %loop.header ] 328 %gep.ptr = getelementptr i32, i32* %ptr, i32 %p 329 store i32 %p, i32* %gep.ptr 330 %add.i = add nsw i32 %p, 1 331 %cmp = icmp slt i32 %add.i, 1000 332 br i1 %cmp, label %loop.header, label %exit 333 334exit: 335 ret void 336} 337