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