1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -S -vectorize-num-stores-pred=1 -force-vector-width=1 -force-vector-interleave=2 -loop-vectorize -verify-loop-info -simplifycfg < %s | FileCheck %s --check-prefix=UNROLL 3; RUN: opt -S -vectorize-num-stores-pred=1 -force-vector-width=1 -force-vector-interleave=2 -loop-vectorize -verify-loop-info < %s | FileCheck %s --check-prefix=UNROLL-NOSIMPLIFY 4; RUN: opt -S -vectorize-num-stores-pred=1 -force-vector-width=2 -force-vector-interleave=1 -loop-vectorize -verify-loop-info -simplifycfg < %s | FileCheck %s --check-prefix=VEC 5 6target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 7 8; Test predication of stores. 9define i32 @test(i32* nocapture %f) #0 { 10; UNROLL-LABEL: @test( 11; UNROLL-NEXT: entry: 12; UNROLL-NEXT: br label [[VECTOR_BODY:%.*]] 13; UNROLL: vector.body: 14; UNROLL-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE3:%.*]] ] 15; UNROLL-NEXT: [[INDUCTION:%.*]] = add i64 [[INDEX]], 0 16; UNROLL-NEXT: [[INDUCTION1:%.*]] = add i64 [[INDEX]], 1 17; UNROLL-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, i32* [[F:%.*]], i64 [[INDUCTION]] 18; UNROLL-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[INDUCTION1]] 19; UNROLL-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP0]], align 4 20; UNROLL-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP1]], align 4 21; UNROLL-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[TMP2]], 100 22; UNROLL-NEXT: [[TMP5:%.*]] = icmp sgt i32 [[TMP3]], 100 23; UNROLL-NEXT: br i1 [[TMP4]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]] 24; UNROLL: pred.store.if: 25; UNROLL-NEXT: [[TMP6:%.*]] = add nsw i32 [[TMP2]], 20 26; UNROLL-NEXT: store i32 [[TMP6]], i32* [[TMP0]], align 4 27; UNROLL-NEXT: br label [[PRED_STORE_CONTINUE]] 28; UNROLL: pred.store.continue: 29; UNROLL-NEXT: br i1 [[TMP5]], label [[PRED_STORE_IF2:%.*]], label [[PRED_STORE_CONTINUE3]] 30; UNROLL: pred.store.if2: 31; UNROLL-NEXT: [[TMP7:%.*]] = add nsw i32 [[TMP3]], 20 32; UNROLL-NEXT: store i32 [[TMP7]], i32* [[TMP1]], align 4 33; UNROLL-NEXT: br label [[PRED_STORE_CONTINUE3]] 34; UNROLL: pred.store.continue3: 35; UNROLL-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 36; UNROLL-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], 128 37; UNROLL-NEXT: br i1 [[TMP8]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]] 38; UNROLL: middle.block: 39; UNROLL-NEXT: [[CMP_N:%.*]] = icmp eq i64 128, 128 40; UNROLL-NEXT: br i1 [[CMP_N]], label [[FOR_END:%.*]], label [[FOR_BODY:%.*]] 41; UNROLL: for.body: 42; UNROLL-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_INC:%.*]] ], [ 128, [[MIDDLE_BLOCK]] ] 43; UNROLL-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[INDVARS_IV]] 44; UNROLL-NEXT: [[TMP9:%.*]] = load i32, i32* [[ARRAYIDX]], align 4 45; UNROLL-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[TMP9]], 100 46; UNROLL-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]] 47; UNROLL: if.then: 48; UNROLL-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP9]], 20 49; UNROLL-NEXT: store i32 [[ADD]], i32* [[ARRAYIDX]], align 4 50; UNROLL-NEXT: br label [[FOR_INC]] 51; UNROLL: for.inc: 52; UNROLL-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1 53; UNROLL-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 128 54; UNROLL-NEXT: br i1 [[EXITCOND]], label [[FOR_END]], label [[FOR_BODY]], [[LOOP2:!llvm.loop !.*]] 55; UNROLL: for.end: 56; UNROLL-NEXT: ret i32 0 57; 58; UNROLL-NOSIMPLIFY-LABEL: @test( 59; UNROLL-NOSIMPLIFY-NEXT: entry: 60; UNROLL-NOSIMPLIFY-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 61; UNROLL-NOSIMPLIFY: vector.ph: 62; UNROLL-NOSIMPLIFY-NEXT: br label [[VECTOR_BODY:%.*]] 63; UNROLL-NOSIMPLIFY: vector.body: 64; UNROLL-NOSIMPLIFY-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE3:%.*]] ] 65; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION:%.*]] = add i64 [[INDEX]], 0 66; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION1:%.*]] = add i64 [[INDEX]], 1 67; UNROLL-NOSIMPLIFY-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, i32* [[F:%.*]], i64 [[INDUCTION]] 68; UNROLL-NOSIMPLIFY-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[INDUCTION1]] 69; UNROLL-NOSIMPLIFY-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP0]], align 4 70; UNROLL-NOSIMPLIFY-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP1]], align 4 71; UNROLL-NOSIMPLIFY-NEXT: [[TMP4:%.*]] = icmp sgt i32 [[TMP2]], 100 72; UNROLL-NOSIMPLIFY-NEXT: [[TMP5:%.*]] = icmp sgt i32 [[TMP3]], 100 73; UNROLL-NOSIMPLIFY-NEXT: br i1 [[TMP4]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]] 74; UNROLL-NOSIMPLIFY: pred.store.if: 75; UNROLL-NOSIMPLIFY-NEXT: [[TMP6:%.*]] = add nsw i32 [[TMP2]], 20 76; UNROLL-NOSIMPLIFY-NEXT: store i32 [[TMP6]], i32* [[TMP0]], align 4 77; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE]] 78; UNROLL-NOSIMPLIFY: pred.store.continue: 79; UNROLL-NOSIMPLIFY-NEXT: br i1 [[TMP5]], label [[PRED_STORE_IF2:%.*]], label [[PRED_STORE_CONTINUE3]] 80; UNROLL-NOSIMPLIFY: pred.store.if2: 81; UNROLL-NOSIMPLIFY-NEXT: [[TMP7:%.*]] = add nsw i32 [[TMP3]], 20 82; UNROLL-NOSIMPLIFY-NEXT: store i32 [[TMP7]], i32* [[TMP1]], align 4 83; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE3]] 84; UNROLL-NOSIMPLIFY: pred.store.continue3: 85; UNROLL-NOSIMPLIFY-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 86; UNROLL-NOSIMPLIFY-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], 128 87; UNROLL-NOSIMPLIFY-NEXT: br i1 [[TMP8]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]] 88; UNROLL-NOSIMPLIFY: middle.block: 89; UNROLL-NOSIMPLIFY-NEXT: [[CMP_N:%.*]] = icmp eq i64 128, 128 90; UNROLL-NOSIMPLIFY-NEXT: br i1 [[CMP_N]], label [[FOR_END:%.*]], label [[SCALAR_PH]] 91; UNROLL-NOSIMPLIFY: scalar.ph: 92; UNROLL-NOSIMPLIFY-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 128, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ] 93; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_BODY:%.*]] 94; UNROLL-NOSIMPLIFY: for.body: 95; UNROLL-NOSIMPLIFY-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_INC:%.*]] ] 96; UNROLL-NOSIMPLIFY-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[INDVARS_IV]] 97; UNROLL-NOSIMPLIFY-NEXT: [[TMP9:%.*]] = load i32, i32* [[ARRAYIDX]], align 4 98; UNROLL-NOSIMPLIFY-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[TMP9]], 100 99; UNROLL-NOSIMPLIFY-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]] 100; UNROLL-NOSIMPLIFY: if.then: 101; UNROLL-NOSIMPLIFY-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP9]], 20 102; UNROLL-NOSIMPLIFY-NEXT: store i32 [[ADD]], i32* [[ARRAYIDX]], align 4 103; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_INC]] 104; UNROLL-NOSIMPLIFY: for.inc: 105; UNROLL-NOSIMPLIFY-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1 106; UNROLL-NOSIMPLIFY-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 128 107; UNROLL-NOSIMPLIFY-NEXT: br i1 [[EXITCOND]], label [[FOR_END]], label [[FOR_BODY]], [[LOOP2:!llvm.loop !.*]] 108; UNROLL-NOSIMPLIFY: for.end: 109; UNROLL-NOSIMPLIFY-NEXT: ret i32 0 110; 111; VEC-LABEL: @test( 112; VEC-NEXT: entry: 113; VEC-NEXT: br label [[VECTOR_BODY:%.*]] 114; VEC: vector.body: 115; VEC-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE2:%.*]] ] 116; VEC-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0 117; VEC-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[F:%.*]], i64 [[TMP0]] 118; VEC-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, i32* [[TMP1]], i32 0 119; VEC-NEXT: [[TMP3:%.*]] = bitcast i32* [[TMP2]] to <2 x i32>* 120; VEC-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i32>, <2 x i32>* [[TMP3]], align 4 121; VEC-NEXT: [[TMP4:%.*]] = icmp sgt <2 x i32> [[WIDE_LOAD]], <i32 100, i32 100> 122; VEC-NEXT: [[TMP5:%.*]] = extractelement <2 x i1> [[TMP4]], i32 0 123; VEC-NEXT: br i1 [[TMP5]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]] 124; VEC: pred.store.if: 125; VEC-NEXT: [[TMP6:%.*]] = extractelement <2 x i32> [[WIDE_LOAD]], i32 0 126; VEC-NEXT: [[TMP7:%.*]] = add nsw i32 [[TMP6]], 20 127; VEC-NEXT: store i32 [[TMP7]], i32* [[TMP1]], align 4 128; VEC-NEXT: br label [[PRED_STORE_CONTINUE]] 129; VEC: pred.store.continue: 130; VEC-NEXT: [[TMP8:%.*]] = extractelement <2 x i1> [[TMP4]], i32 1 131; VEC-NEXT: br i1 [[TMP8]], label [[PRED_STORE_IF1:%.*]], label [[PRED_STORE_CONTINUE2]] 132; VEC: pred.store.if1: 133; VEC-NEXT: [[TMP9:%.*]] = extractelement <2 x i32> [[WIDE_LOAD]], i32 1 134; VEC-NEXT: [[TMP10:%.*]] = add nsw i32 [[TMP9]], 20 135; VEC-NEXT: [[TMP11:%.*]] = add i64 [[INDEX]], 1 136; VEC-NEXT: [[TMP12:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[TMP11]] 137; VEC-NEXT: store i32 [[TMP10]], i32* [[TMP12]], align 4 138; VEC-NEXT: br label [[PRED_STORE_CONTINUE2]] 139; VEC: pred.store.continue2: 140; VEC-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 141; VEC-NEXT: [[TMP13:%.*]] = icmp eq i64 [[INDEX_NEXT]], 128 142; VEC-NEXT: br i1 [[TMP13]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP0:!llvm.loop !.*]] 143; VEC: middle.block: 144; VEC-NEXT: [[CMP_N:%.*]] = icmp eq i64 128, 128 145; VEC-NEXT: br i1 [[CMP_N]], label [[FOR_END:%.*]], label [[FOR_BODY:%.*]] 146; VEC: for.body: 147; VEC-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[FOR_INC:%.*]] ], [ 128, [[MIDDLE_BLOCK]] ] 148; VEC-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[F]], i64 [[INDVARS_IV]] 149; VEC-NEXT: [[TMP14:%.*]] = load i32, i32* [[ARRAYIDX]], align 4 150; VEC-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[TMP14]], 100 151; VEC-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[FOR_INC]] 152; VEC: if.then: 153; VEC-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP14]], 20 154; VEC-NEXT: store i32 [[ADD]], i32* [[ARRAYIDX]], align 4 155; VEC-NEXT: br label [[FOR_INC]] 156; VEC: for.inc: 157; VEC-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1 158; VEC-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 128 159; VEC-NEXT: br i1 [[EXITCOND]], label [[FOR_END]], label [[FOR_BODY]], [[LOOP2:!llvm.loop !.*]] 160; VEC: for.end: 161; VEC-NEXT: ret i32 0 162; 163entry: 164 br label %for.body 165 166 167 168for.body: 169 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ] 170 %arrayidx = getelementptr inbounds i32, i32* %f, i64 %indvars.iv 171 %0 = load i32, i32* %arrayidx, align 4 172 %cmp1 = icmp sgt i32 %0, 100 173 br i1 %cmp1, label %if.then, label %for.inc 174 175if.then: 176 %add = add nsw i32 %0, 20 177 store i32 %add, i32* %arrayidx, align 4 178 br label %for.inc 179 180for.inc: 181 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 182 %exitcond = icmp eq i64 %indvars.iv.next, 128 183 br i1 %exitcond, label %for.end, label %for.body 184 185for.end: 186 ret i32 0 187} 188 189; Track basic blocks when unrolling conditional blocks. This code used to assert 190; because we did not update the phi nodes with the proper predecessor in the 191; vectorized loop body. 192; PR18724 193 194define void @bug18724(i1 %cond) { 195; UNROLL-LABEL: @bug18724( 196; UNROLL-NEXT: entry: 197; UNROLL-NEXT: [[TMP0:%.*]] = xor i1 [[COND:%.*]], true 198; UNROLL-NEXT: call void @llvm.assume(i1 [[TMP0]]) 199; UNROLL-NEXT: br label [[FOR_BODY14:%.*]] 200; UNROLL: for.body14: 201; UNROLL-NEXT: [[INDVARS_IV3:%.*]] = phi i64 [ [[INDVARS_IV_NEXT4:%.*]], [[FOR_INC23:%.*]] ], [ undef, [[ENTRY:%.*]] ] 202; UNROLL-NEXT: [[INEWCHUNKS_120:%.*]] = phi i32 [ [[INEWCHUNKS_2:%.*]], [[FOR_INC23]] ], [ undef, [[ENTRY]] ] 203; UNROLL-NEXT: [[ARRAYIDX16:%.*]] = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 [[INDVARS_IV3]] 204; UNROLL-NEXT: [[TMP:%.*]] = load i32, i32* [[ARRAYIDX16]], align 4 205; UNROLL-NEXT: br i1 undef, label [[IF_THEN18:%.*]], label [[FOR_INC23]] 206; UNROLL: if.then18: 207; UNROLL-NEXT: store i32 2, i32* [[ARRAYIDX16]], align 4 208; UNROLL-NEXT: [[INC21:%.*]] = add nsw i32 [[INEWCHUNKS_120]], 1 209; UNROLL-NEXT: br label [[FOR_INC23]] 210; UNROLL: for.inc23: 211; UNROLL-NEXT: [[INEWCHUNKS_2]] = phi i32 [ [[INC21]], [[IF_THEN18]] ], [ [[INEWCHUNKS_120]], [[FOR_BODY14]] ] 212; UNROLL-NEXT: [[INDVARS_IV_NEXT4]] = add nsw i64 [[INDVARS_IV3]], 1 213; UNROLL-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV3]] to i32 214; UNROLL-NEXT: [[CMP13:%.*]] = icmp slt i32 [[TMP1]], 0 215; UNROLL-NEXT: call void @llvm.assume(i1 [[CMP13]]) 216; UNROLL-NEXT: br label [[FOR_BODY14]] 217; 218; UNROLL-NOSIMPLIFY-LABEL: @bug18724( 219; UNROLL-NOSIMPLIFY-NEXT: entry: 220; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_BODY9:%.*]] 221; UNROLL-NOSIMPLIFY: for.body9: 222; UNROLL-NOSIMPLIFY-NEXT: br i1 [[COND:%.*]], label [[FOR_INC26:%.*]], label [[FOR_BODY14_PREHEADER:%.*]] 223; UNROLL-NOSIMPLIFY: for.body14.preheader: 224; UNROLL-NOSIMPLIFY-NEXT: br i1 true, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 225; UNROLL-NOSIMPLIFY: vector.ph: 226; UNROLL-NOSIMPLIFY-NEXT: br label [[VECTOR_BODY:%.*]] 227; UNROLL-NOSIMPLIFY: vector.body: 228; UNROLL-NOSIMPLIFY-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE4:%.*]] ] 229; UNROLL-NOSIMPLIFY-NEXT: [[VEC_PHI:%.*]] = phi i32 [ undef, [[VECTOR_PH]] ], [ [[PREDPHI:%.*]], [[PRED_STORE_CONTINUE4]] ] 230; UNROLL-NOSIMPLIFY-NEXT: [[VEC_PHI2:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[PREDPHI5:%.*]], [[PRED_STORE_CONTINUE4]] ] 231; UNROLL-NOSIMPLIFY-NEXT: [[OFFSET_IDX:%.*]] = add i64 undef, [[INDEX]] 232; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION:%.*]] = add i64 [[OFFSET_IDX]], 0 233; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION1:%.*]] = add i64 [[OFFSET_IDX]], 1 234; UNROLL-NOSIMPLIFY-NEXT: [[TMP0:%.*]] = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 [[INDUCTION]] 235; UNROLL-NOSIMPLIFY-NEXT: [[TMP1:%.*]] = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 [[INDUCTION1]] 236; UNROLL-NOSIMPLIFY-NEXT: [[TMP2:%.*]] = load i32, i32* [[TMP0]], align 4 237; UNROLL-NOSIMPLIFY-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP1]], align 4 238; UNROLL-NOSIMPLIFY-NEXT: br i1 undef, label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]] 239; UNROLL-NOSIMPLIFY: pred.store.if: 240; UNROLL-NOSIMPLIFY-NEXT: store i32 2, i32* [[TMP0]], align 4 241; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE]] 242; UNROLL-NOSIMPLIFY: pred.store.continue: 243; UNROLL-NOSIMPLIFY-NEXT: br i1 undef, label [[PRED_STORE_IF3:%.*]], label [[PRED_STORE_CONTINUE4]] 244; UNROLL-NOSIMPLIFY: pred.store.if3: 245; UNROLL-NOSIMPLIFY-NEXT: store i32 2, i32* [[TMP1]], align 4 246; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE4]] 247; UNROLL-NOSIMPLIFY: pred.store.continue4: 248; UNROLL-NOSIMPLIFY-NEXT: [[TMP4:%.*]] = add i32 [[VEC_PHI]], 1 249; UNROLL-NOSIMPLIFY-NEXT: [[TMP5:%.*]] = add i32 [[VEC_PHI2]], 1 250; UNROLL-NOSIMPLIFY-NEXT: [[PREDPHI]] = select i1 undef, i32 [[VEC_PHI]], i32 [[TMP4]] 251; UNROLL-NOSIMPLIFY-NEXT: [[PREDPHI5]] = select i1 undef, i32 [[VEC_PHI2]], i32 [[TMP5]] 252; UNROLL-NOSIMPLIFY-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 253; UNROLL-NOSIMPLIFY-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], 0 254; UNROLL-NOSIMPLIFY-NEXT: br i1 [[TMP6]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP3:!llvm.loop !.*]] 255; UNROLL-NOSIMPLIFY: middle.block: 256; UNROLL-NOSIMPLIFY-NEXT: [[BIN_RDX:%.*]] = add i32 [[PREDPHI5]], [[PREDPHI]] 257; UNROLL-NOSIMPLIFY-NEXT: [[CMP_N:%.*]] = icmp eq i64 1, 0 258; UNROLL-NOSIMPLIFY-NEXT: br i1 [[CMP_N]], label [[FOR_INC26_LOOPEXIT:%.*]], label [[SCALAR_PH]] 259; UNROLL-NOSIMPLIFY: scalar.ph: 260; UNROLL-NOSIMPLIFY-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ undef, [[MIDDLE_BLOCK]] ], [ undef, [[FOR_BODY14_PREHEADER]] ] 261; UNROLL-NOSIMPLIFY-NEXT: [[BC_MERGE_RDX:%.*]] = phi i32 [ undef, [[FOR_BODY14_PREHEADER]] ], [ [[BIN_RDX]], [[MIDDLE_BLOCK]] ] 262; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_BODY14:%.*]] 263; UNROLL-NOSIMPLIFY: for.body14: 264; UNROLL-NOSIMPLIFY-NEXT: [[INDVARS_IV3:%.*]] = phi i64 [ [[INDVARS_IV_NEXT4:%.*]], [[FOR_INC23:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] 265; UNROLL-NOSIMPLIFY-NEXT: [[INEWCHUNKS_120:%.*]] = phi i32 [ [[INEWCHUNKS_2:%.*]], [[FOR_INC23]] ], [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ] 266; UNROLL-NOSIMPLIFY-NEXT: [[ARRAYIDX16:%.*]] = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 [[INDVARS_IV3]] 267; UNROLL-NOSIMPLIFY-NEXT: [[TMP:%.*]] = load i32, i32* [[ARRAYIDX16]], align 4 268; UNROLL-NOSIMPLIFY-NEXT: br i1 undef, label [[IF_THEN18:%.*]], label [[FOR_INC23]] 269; UNROLL-NOSIMPLIFY: if.then18: 270; UNROLL-NOSIMPLIFY-NEXT: store i32 2, i32* [[ARRAYIDX16]], align 4 271; UNROLL-NOSIMPLIFY-NEXT: [[INC21:%.*]] = add nsw i32 [[INEWCHUNKS_120]], 1 272; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_INC23]] 273; UNROLL-NOSIMPLIFY: for.inc23: 274; UNROLL-NOSIMPLIFY-NEXT: [[INEWCHUNKS_2]] = phi i32 [ [[INC21]], [[IF_THEN18]] ], [ [[INEWCHUNKS_120]], [[FOR_BODY14]] ] 275; UNROLL-NOSIMPLIFY-NEXT: [[INDVARS_IV_NEXT4]] = add nsw i64 [[INDVARS_IV3]], 1 276; UNROLL-NOSIMPLIFY-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV3]] to i32 277; UNROLL-NOSIMPLIFY-NEXT: [[CMP13:%.*]] = icmp slt i32 [[TMP1]], 0 278; UNROLL-NOSIMPLIFY-NEXT: br i1 [[CMP13]], label [[FOR_BODY14]], label [[FOR_INC26_LOOPEXIT]], [[LOOP4:!llvm.loop !.*]] 279; UNROLL-NOSIMPLIFY: for.inc26.loopexit: 280; UNROLL-NOSIMPLIFY-NEXT: [[INEWCHUNKS_2_LCSSA:%.*]] = phi i32 [ [[INEWCHUNKS_2]], [[FOR_INC23]] ], [ [[BIN_RDX]], [[MIDDLE_BLOCK]] ] 281; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_INC26]] 282; UNROLL-NOSIMPLIFY: for.inc26: 283; UNROLL-NOSIMPLIFY-NEXT: [[INEWCHUNKS_1_LCSSA:%.*]] = phi i32 [ undef, [[FOR_BODY9]] ], [ [[INEWCHUNKS_2_LCSSA]], [[FOR_INC26_LOOPEXIT]] ] 284; UNROLL-NOSIMPLIFY-NEXT: unreachable 285; 286; VEC-LABEL: @bug18724( 287; VEC-NEXT: entry: 288; VEC-NEXT: [[TMP0:%.*]] = xor i1 [[COND:%.*]], true 289; VEC-NEXT: call void @llvm.assume(i1 [[TMP0]]) 290; VEC-NEXT: br label [[FOR_BODY14:%.*]] 291; VEC: for.body14: 292; VEC-NEXT: [[INDVARS_IV3:%.*]] = phi i64 [ [[INDVARS_IV_NEXT4:%.*]], [[FOR_INC23:%.*]] ], [ undef, [[ENTRY:%.*]] ] 293; VEC-NEXT: [[INEWCHUNKS_120:%.*]] = phi i32 [ [[INEWCHUNKS_2:%.*]], [[FOR_INC23]] ], [ undef, [[ENTRY]] ] 294; VEC-NEXT: [[ARRAYIDX16:%.*]] = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 [[INDVARS_IV3]] 295; VEC-NEXT: [[TMP:%.*]] = load i32, i32* [[ARRAYIDX16]], align 4 296; VEC-NEXT: br i1 undef, label [[IF_THEN18:%.*]], label [[FOR_INC23]] 297; VEC: if.then18: 298; VEC-NEXT: store i32 2, i32* [[ARRAYIDX16]], align 4 299; VEC-NEXT: [[INC21:%.*]] = add nsw i32 [[INEWCHUNKS_120]], 1 300; VEC-NEXT: br label [[FOR_INC23]] 301; VEC: for.inc23: 302; VEC-NEXT: [[INEWCHUNKS_2]] = phi i32 [ [[INC21]], [[IF_THEN18]] ], [ [[INEWCHUNKS_120]], [[FOR_BODY14]] ] 303; VEC-NEXT: [[INDVARS_IV_NEXT4]] = add nsw i64 [[INDVARS_IV3]], 1 304; VEC-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV3]] to i32 305; VEC-NEXT: [[CMP13:%.*]] = icmp slt i32 [[TMP1]], 0 306; VEC-NEXT: call void @llvm.assume(i1 [[CMP13]]) 307; VEC-NEXT: br label [[FOR_BODY14]] 308; 309entry: 310 br label %for.body9 311 312for.body9: 313 br i1 %cond, label %for.inc26, label %for.body14 314 315for.body14: 316 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc23 ], [ undef, %for.body9 ] 317 %iNewChunks.120 = phi i32 [ %iNewChunks.2, %for.inc23 ], [ undef, %for.body9 ] 318 %arrayidx16 = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 %indvars.iv3 319 %tmp = load i32, i32* %arrayidx16, align 4 320 br i1 undef, label %if.then18, label %for.inc23 321 322if.then18: 323 store i32 2, i32* %arrayidx16, align 4 324 %inc21 = add nsw i32 %iNewChunks.120, 1 325 br label %for.inc23 326 327for.inc23: 328 %iNewChunks.2 = phi i32 [ %inc21, %if.then18 ], [ %iNewChunks.120, %for.body14 ] 329 %indvars.iv.next4 = add nsw i64 %indvars.iv3, 1 330 %tmp1 = trunc i64 %indvars.iv3 to i32 331 %cmp13 = icmp slt i32 %tmp1, 0 332 br i1 %cmp13, label %for.body14, label %for.inc26 333 334for.inc26: 335 %iNewChunks.1.lcssa = phi i32 [ undef, %for.body9 ], [ %iNewChunks.2, %for.inc23 ] 336 unreachable 337} 338 339; In the test below, it's more profitable for the expression feeding the 340; conditional store to remain scalar. Since we can only type-shrink vector 341; types, we shouldn't try to represent the expression in a smaller type. 342; 343define void @minimal_bit_widths(i1 %c) { 344; UNROLL-LABEL: @minimal_bit_widths( 345; UNROLL-NEXT: entry: 346; UNROLL-NEXT: br label [[VECTOR_BODY:%.*]] 347; UNROLL: vector.body: 348; UNROLL-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE6:%.*]] ] 349; UNROLL-NEXT: [[OFFSET_IDX:%.*]] = sub i64 undef, [[INDEX]] 350; UNROLL-NEXT: [[INDUCTION3:%.*]] = add i64 [[OFFSET_IDX]], 0 351; UNROLL-NEXT: [[INDUCTION4:%.*]] = add i64 [[OFFSET_IDX]], -1 352; UNROLL-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE6]] 353; UNROLL: pred.store.if: 354; UNROLL-NEXT: [[INDUCTION:%.*]] = add i64 [[INDEX]], 0 355; UNROLL-NEXT: [[TMP0:%.*]] = getelementptr i8, i8* undef, i64 [[INDUCTION]] 356; UNROLL-NEXT: [[TMP1:%.*]] = load i8, i8* [[TMP0]], align 1 357; UNROLL-NEXT: [[TMP2:%.*]] = zext i8 [[TMP1]] to i32 358; UNROLL-NEXT: [[TMP3:%.*]] = trunc i32 [[TMP2]] to i8 359; UNROLL-NEXT: store i8 [[TMP3]], i8* [[TMP0]], align 1 360; UNROLL-NEXT: [[INDUCTION2:%.*]] = add i64 [[INDEX]], 1 361; UNROLL-NEXT: [[TMP4:%.*]] = getelementptr i8, i8* undef, i64 [[INDUCTION2]] 362; UNROLL-NEXT: [[TMP5:%.*]] = load i8, i8* [[TMP4]], align 1 363; UNROLL-NEXT: [[TMP6:%.*]] = zext i8 [[TMP5]] to i32 364; UNROLL-NEXT: [[TMP7:%.*]] = trunc i32 [[TMP6]] to i8 365; UNROLL-NEXT: store i8 [[TMP7]], i8* [[TMP4]], align 1 366; UNROLL-NEXT: br label [[PRED_STORE_CONTINUE6]] 367; UNROLL: pred.store.continue6: 368; UNROLL-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 369; UNROLL-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], undef 370; UNROLL-NEXT: br i1 [[TMP8]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP3:!llvm.loop !.*]] 371; UNROLL: middle.block: 372; UNROLL-NEXT: [[CMP_N:%.*]] = icmp eq i64 undef, undef 373; UNROLL-NEXT: br i1 [[CMP_N]], label [[FOR_END:%.*]], label [[FOR_BODY:%.*]] 374; UNROLL: for.body: 375; UNROLL-NEXT: [[TMP0:%.*]] = phi i64 [ [[TMP6:%.*]], [[FOR_INC:%.*]] ], [ undef, [[MIDDLE_BLOCK]] ] 376; UNROLL-NEXT: [[TMP1:%.*]] = phi i64 [ [[TMP7:%.*]], [[FOR_INC]] ], [ undef, [[MIDDLE_BLOCK]] ] 377; UNROLL-NEXT: [[TMP2:%.*]] = getelementptr i8, i8* undef, i64 [[TMP0]] 378; UNROLL-NEXT: [[TMP3:%.*]] = load i8, i8* [[TMP2]], align 1 379; UNROLL-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[FOR_INC]] 380; UNROLL: if.then: 381; UNROLL-NEXT: [[TMP4:%.*]] = zext i8 [[TMP3]] to i32 382; UNROLL-NEXT: [[TMP5:%.*]] = trunc i32 [[TMP4]] to i8 383; UNROLL-NEXT: store i8 [[TMP5]], i8* [[TMP2]], align 1 384; UNROLL-NEXT: br label [[FOR_INC]] 385; UNROLL: for.inc: 386; UNROLL-NEXT: [[TMP6]] = add nuw nsw i64 [[TMP0]], 1 387; UNROLL-NEXT: [[TMP7]] = add i64 [[TMP1]], -1 388; UNROLL-NEXT: [[TMP8:%.*]] = icmp eq i64 [[TMP7]], 0 389; UNROLL-NEXT: br i1 [[TMP8]], label [[FOR_END]], label [[FOR_BODY]], [[LOOP4:!llvm.loop !.*]] 390; UNROLL: for.end: 391; UNROLL-NEXT: ret void 392; 393; UNROLL-NOSIMPLIFY-LABEL: @minimal_bit_widths( 394; UNROLL-NOSIMPLIFY-NEXT: entry: 395; UNROLL-NOSIMPLIFY-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] 396; UNROLL-NOSIMPLIFY: vector.ph: 397; UNROLL-NOSIMPLIFY-NEXT: br label [[VECTOR_BODY:%.*]] 398; UNROLL-NOSIMPLIFY: vector.body: 399; UNROLL-NOSIMPLIFY-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE6:%.*]] ] 400; UNROLL-NOSIMPLIFY-NEXT: [[OFFSET_IDX:%.*]] = sub i64 undef, [[INDEX]] 401; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION3:%.*]] = add i64 [[OFFSET_IDX]], 0 402; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION4:%.*]] = add i64 [[OFFSET_IDX]], -1 403; UNROLL-NOSIMPLIFY-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]] 404; UNROLL-NOSIMPLIFY: pred.store.if: 405; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION:%.*]] = add i64 [[INDEX]], 0 406; UNROLL-NOSIMPLIFY-NEXT: [[TMP0:%.*]] = getelementptr i8, i8* undef, i64 [[INDUCTION]] 407; UNROLL-NOSIMPLIFY-NEXT: [[TMP1:%.*]] = load i8, i8* [[TMP0]], align 1 408; UNROLL-NOSIMPLIFY-NEXT: [[TMP2:%.*]] = zext i8 [[TMP1]] to i32 409; UNROLL-NOSIMPLIFY-NEXT: [[TMP3:%.*]] = trunc i32 [[TMP2]] to i8 410; UNROLL-NOSIMPLIFY-NEXT: store i8 [[TMP3]], i8* [[TMP0]], align 1 411; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE]] 412; UNROLL-NOSIMPLIFY: pred.store.continue: 413; UNROLL-NOSIMPLIFY-NEXT: br i1 [[C]], label [[PRED_STORE_IF5:%.*]], label [[PRED_STORE_CONTINUE6]] 414; UNROLL-NOSIMPLIFY: pred.store.if5: 415; UNROLL-NOSIMPLIFY-NEXT: [[INDUCTION2:%.*]] = add i64 [[INDEX]], 1 416; UNROLL-NOSIMPLIFY-NEXT: [[TMP4:%.*]] = getelementptr i8, i8* undef, i64 [[INDUCTION2]] 417; UNROLL-NOSIMPLIFY-NEXT: [[TMP5:%.*]] = load i8, i8* [[TMP4]], align 1 418; UNROLL-NOSIMPLIFY-NEXT: [[TMP6:%.*]] = zext i8 [[TMP5]] to i32 419; UNROLL-NOSIMPLIFY-NEXT: [[TMP7:%.*]] = trunc i32 [[TMP6]] to i8 420; UNROLL-NOSIMPLIFY-NEXT: store i8 [[TMP7]], i8* [[TMP4]], align 1 421; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE6]] 422; UNROLL-NOSIMPLIFY: pred.store.continue6: 423; UNROLL-NOSIMPLIFY-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 424; UNROLL-NOSIMPLIFY-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], undef 425; UNROLL-NOSIMPLIFY-NEXT: br i1 [[TMP8]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP5:!llvm.loop !.*]] 426; UNROLL-NOSIMPLIFY: middle.block: 427; UNROLL-NOSIMPLIFY-NEXT: [[CMP_N:%.*]] = icmp eq i64 undef, undef 428; UNROLL-NOSIMPLIFY-NEXT: br i1 [[CMP_N]], label [[FOR_END:%.*]], label [[SCALAR_PH]] 429; UNROLL-NOSIMPLIFY: scalar.ph: 430; UNROLL-NOSIMPLIFY-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ undef, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ] 431; UNROLL-NOSIMPLIFY-NEXT: [[BC_RESUME_VAL1:%.*]] = phi i64 [ undef, [[MIDDLE_BLOCK]] ], [ undef, [[ENTRY]] ] 432; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_BODY:%.*]] 433; UNROLL-NOSIMPLIFY: for.body: 434; UNROLL-NOSIMPLIFY-NEXT: [[TMP0:%.*]] = phi i64 [ [[TMP6:%.*]], [[FOR_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] 435; UNROLL-NOSIMPLIFY-NEXT: [[TMP1:%.*]] = phi i64 [ [[TMP7:%.*]], [[FOR_INC]] ], [ [[BC_RESUME_VAL1]], [[SCALAR_PH]] ] 436; UNROLL-NOSIMPLIFY-NEXT: [[TMP2:%.*]] = getelementptr i8, i8* undef, i64 [[TMP0]] 437; UNROLL-NOSIMPLIFY-NEXT: [[TMP3:%.*]] = load i8, i8* [[TMP2]], align 1 438; UNROLL-NOSIMPLIFY-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[FOR_INC]] 439; UNROLL-NOSIMPLIFY: if.then: 440; UNROLL-NOSIMPLIFY-NEXT: [[TMP4:%.*]] = zext i8 [[TMP3]] to i32 441; UNROLL-NOSIMPLIFY-NEXT: [[TMP5:%.*]] = trunc i32 [[TMP4]] to i8 442; UNROLL-NOSIMPLIFY-NEXT: store i8 [[TMP5]], i8* [[TMP2]], align 1 443; UNROLL-NOSIMPLIFY-NEXT: br label [[FOR_INC]] 444; UNROLL-NOSIMPLIFY: for.inc: 445; UNROLL-NOSIMPLIFY-NEXT: [[TMP6]] = add nuw nsw i64 [[TMP0]], 1 446; UNROLL-NOSIMPLIFY-NEXT: [[TMP7]] = add i64 [[TMP1]], -1 447; UNROLL-NOSIMPLIFY-NEXT: [[TMP8:%.*]] = icmp eq i64 [[TMP7]], 0 448; UNROLL-NOSIMPLIFY-NEXT: br i1 [[TMP8]], label [[FOR_END]], label [[FOR_BODY]], [[LOOP6:!llvm.loop !.*]] 449; UNROLL-NOSIMPLIFY: for.end: 450; UNROLL-NOSIMPLIFY-NEXT: ret void 451; 452; VEC-LABEL: @minimal_bit_widths( 453; VEC-NEXT: entry: 454; VEC-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i1> undef, i1 [[C:%.*]], i32 0 455; VEC-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i1> [[BROADCAST_SPLATINSERT]], <2 x i1> undef, <2 x i32> zeroinitializer 456; VEC-NEXT: br label [[VECTOR_BODY:%.*]] 457; VEC: vector.body: 458; VEC-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE3:%.*]] ] 459; VEC-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0 460; VEC-NEXT: [[OFFSET_IDX:%.*]] = sub i64 undef, [[INDEX]] 461; VEC-NEXT: [[TMP1:%.*]] = add i64 [[OFFSET_IDX]], 0 462; VEC-NEXT: [[TMP2:%.*]] = getelementptr i8, i8* undef, i64 [[TMP0]] 463; VEC-NEXT: [[TMP3:%.*]] = getelementptr i8, i8* [[TMP2]], i32 0 464; VEC-NEXT: [[TMP4:%.*]] = bitcast i8* [[TMP3]] to <2 x i8>* 465; VEC-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i8>, <2 x i8>* [[TMP4]], align 1 466; VEC-NEXT: [[TMP5:%.*]] = extractelement <2 x i1> [[BROADCAST_SPLAT]], i32 0 467; VEC-NEXT: br i1 [[TMP5]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]] 468; VEC: pred.store.if: 469; VEC-NEXT: [[TMP6:%.*]] = extractelement <2 x i8> [[WIDE_LOAD]], i32 0 470; VEC-NEXT: [[TMP7:%.*]] = zext i8 [[TMP6]] to i32 471; VEC-NEXT: [[TMP8:%.*]] = trunc i32 [[TMP7]] to i8 472; VEC-NEXT: store i8 [[TMP8]], i8* [[TMP2]], align 1 473; VEC-NEXT: br label [[PRED_STORE_CONTINUE]] 474; VEC: pred.store.continue: 475; VEC-NEXT: [[TMP9:%.*]] = extractelement <2 x i1> [[BROADCAST_SPLAT]], i32 1 476; VEC-NEXT: br i1 [[TMP9]], label [[PRED_STORE_IF2:%.*]], label [[PRED_STORE_CONTINUE3]] 477; VEC: pred.store.if2: 478; VEC-NEXT: [[TMP10:%.*]] = extractelement <2 x i8> [[WIDE_LOAD]], i32 1 479; VEC-NEXT: [[TMP11:%.*]] = zext i8 [[TMP10]] to i32 480; VEC-NEXT: [[TMP12:%.*]] = trunc i32 [[TMP11]] to i8 481; VEC-NEXT: [[TMP13:%.*]] = add i64 [[INDEX]], 1 482; VEC-NEXT: [[TMP14:%.*]] = getelementptr i8, i8* undef, i64 [[TMP13]] 483; VEC-NEXT: store i8 [[TMP12]], i8* [[TMP14]], align 1 484; VEC-NEXT: br label [[PRED_STORE_CONTINUE3]] 485; VEC: pred.store.continue3: 486; VEC-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], 2 487; VEC-NEXT: [[TMP15:%.*]] = icmp eq i64 [[INDEX_NEXT]], undef 488; VEC-NEXT: br i1 [[TMP15]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], [[LOOP4:!llvm.loop !.*]] 489; VEC: middle.block: 490; VEC-NEXT: [[CMP_N:%.*]] = icmp eq i64 undef, undef 491; VEC-NEXT: br i1 [[CMP_N]], label [[FOR_END:%.*]], label [[FOR_BODY:%.*]] 492; VEC: for.body: 493; VEC-NEXT: [[TMP0:%.*]] = phi i64 [ [[TMP6:%.*]], [[FOR_INC:%.*]] ], [ undef, [[MIDDLE_BLOCK]] ] 494; VEC-NEXT: [[TMP1:%.*]] = phi i64 [ [[TMP7:%.*]], [[FOR_INC]] ], [ undef, [[MIDDLE_BLOCK]] ] 495; VEC-NEXT: [[TMP2:%.*]] = getelementptr i8, i8* undef, i64 [[TMP0]] 496; VEC-NEXT: [[TMP3:%.*]] = load i8, i8* [[TMP2]], align 1 497; VEC-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[FOR_INC]] 498; VEC: if.then: 499; VEC-NEXT: [[TMP4:%.*]] = zext i8 [[TMP3]] to i32 500; VEC-NEXT: [[TMP5:%.*]] = trunc i32 [[TMP4]] to i8 501; VEC-NEXT: store i8 [[TMP5]], i8* [[TMP2]], align 1 502; VEC-NEXT: br label [[FOR_INC]] 503; VEC: for.inc: 504; VEC-NEXT: [[TMP6]] = add nuw nsw i64 [[TMP0]], 1 505; VEC-NEXT: [[TMP7]] = add i64 [[TMP1]], -1 506; VEC-NEXT: [[TMP8:%.*]] = icmp eq i64 [[TMP7]], 0 507; VEC-NEXT: br i1 [[TMP8]], label [[FOR_END]], label [[FOR_BODY]], [[LOOP5:!llvm.loop !.*]] 508; VEC: for.end: 509; VEC-NEXT: ret void 510; 511entry: 512 br label %for.body 513 514for.body: 515 %tmp0 = phi i64 [ %tmp6, %for.inc ], [ 0, %entry ] 516 %tmp1 = phi i64 [ %tmp7, %for.inc ], [ undef, %entry ] 517 %tmp2 = getelementptr i8, i8* undef, i64 %tmp0 518 %tmp3 = load i8, i8* %tmp2, align 1 519 br i1 %c, label %if.then, label %for.inc 520 521if.then: 522 %tmp4 = zext i8 %tmp3 to i32 523 %tmp5 = trunc i32 %tmp4 to i8 524 store i8 %tmp5, i8* %tmp2, align 1 525 br label %for.inc 526 527for.inc: 528 %tmp6 = add nuw nsw i64 %tmp0, 1 529 %tmp7 = add i64 %tmp1, -1 530 %tmp8 = icmp eq i64 %tmp7, 0 531 br i1 %tmp8, label %for.end, label %for.body 532 533for.end: 534 ret void 535} 536