64 lines · plain
1; RUN: opt -passes='loop-vectorize' -debug -S < %s 2>&1 | FileCheck %s2; REQUIRES: asserts3 4; This checks we don't crash when the inner loop we're trying to vectorize5; is a SCEV AddRec with respect to an outer loop.6 7; In this case, the problematic PHI is:8; %0 = phi i32 [ poison, %for.cond1.preheader ], [ %inc54, %for.body3 ]9; Since %inc54 is the IV of the outer loop, and %0 equivalent to it,10; we get the situation described above.11 12; Code that leads to this situation can look something like:13;14; int a, b[1], c;15; void fn1 ()16; {17; for (; c; c++)18; for (a = 0; a; a++)19; b[c] = 4;20; }21;22; The PHI is an artifact of the register promotion of c.23 24; Note that we can no longer get the vectorizer to actually see such PHIs,25; because LV now simplifies the loop internally, but the test is still26; useful as a regression test, and in case loop-simplify behavior changes.27 28@c = external global i32, align 429@a = external global i32, align 430@b = external global [1 x i32], align 431 32; We can vectorize this loop because we are storing an invariant value into an33; invariant address.34 35; CHECK: LV: We can vectorize this loop!36; CHECK-LABEL: @test37define void @test() {38entry:39 %a.promoted2 = load i32, ptr @a, align 140 %c.promoted = load i32, ptr @c, align 141 br label %for.cond1.preheader42 43for.cond1.preheader: ; preds = %for.cond1.for.inc4_crit_edge, %entry44 %inc54 = phi i32 [ %inc5, %for.cond1.for.inc4_crit_edge ], [ %c.promoted, %entry ]45 %inc.lcssa3 = phi i32 [ %inc.lcssa, %for.cond1.for.inc4_crit_edge ], [ %a.promoted2, %entry ]46 br label %for.body347 48for.body3: ; preds = %for.body3, %for.cond1.preheader49 %inc1 = phi i32 [ %inc.lcssa3, %for.cond1.preheader ], [ %inc, %for.body3 ]50 %0 = phi i32 [ poison, %for.cond1.preheader ], [ %inc54, %for.body3 ]51 %idxprom = sext i32 %0 to i6452 %arrayidx = getelementptr inbounds [1 x i32], ptr @b, i64 0, i64 %idxprom53 store i32 4, ptr %arrayidx, align 454 %inc = add nsw i32 %inc1, 155 %tobool2 = icmp eq i32 %inc, 056 br i1 %tobool2, label %for.cond1.for.inc4_crit_edge, label %for.body357 58for.cond1.for.inc4_crit_edge: ; preds = %for.body359 %inc.lcssa = phi i32 [ %inc, %for.body3 ]60 %.lcssa = phi i32 [ %inc54, %for.body3 ]61 %inc5 = add nsw i32 %.lcssa, 162 br label %for.cond1.preheader63}64