diff options
Diffstat (limited to 'test/Transforms/IndVarSimplify')
26 files changed, 327 insertions, 383 deletions
diff --git a/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll b/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll index 77354f7..af9f1b3 100644 --- a/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll +++ b/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s ; Test WidenIV::GetExtendedOperandRecurrence. ; add219 should be extended to i64 because it is nsw, even though its ; sext cannot be hoisted outside the loop. @@ -19,7 +19,7 @@ for.body153: ; preds = %for.body153, %for.b ; CHECK: add nsw i64 %indvars.iv, 1 for.body170: ; preds = %for.body170, %for.body153 - %i2.19 = phi i32 [ %add249, %for.body170 ], [ undef, %for.body153 ] + %i2.19 = phi i32 [ %add249, %for.body170 ], [ 0, %for.body153 ] %add219 = add nsw i32 %i2.19, 1 %idxprom220 = sext i32 %add219 to i64 %add249 = add nsw i32 %i2.19, %shl132 diff --git a/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll b/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll new file mode 100644 index 0000000..76c90e0 --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll @@ -0,0 +1,59 @@ +; RUN: opt < %s -indvars -S | FileCheck %s +; rdar://10359193: assert "IndVar type must match IVInit type" + +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32" +target triple = "thumbv7-apple-darwin" + +; CHECK: @test +; CHECK: if.end.i126: +; CHECK: %exitcond = icmp ne i8* %incdec.ptr.i, getelementptr (i8* null, i32 undef) +define void @test() nounwind { +entry: + br label %while.cond + +while.cond: + br i1 undef, label %while.end, label %while.body + +while.body: ; preds = %while.cond + br i1 undef, label %if.then165, label %while.cond + +if.then165: ; preds = %while.body + br i1 undef, label %while.cond, label %for.body.lr.ph.i81 + +for.body.lr.ph.i81: ; preds = %if.then165 + br label %for.body.i86 + +for.body.i86: ; preds = %for.end.i129, %for.body.lr.ph.i81 + %cmp196.i = icmp ult i32 0, undef + br i1 %cmp196.i, label %for.body21.lr.ph.i, label %for.end.i129 + +for.body21.lr.ph.i: ; preds = %for.body.i86 + br label %for.body21.i + +for.body21.i: + %destYPixelPtr.010.i = phi i8* [ null, %for.body21.lr.ph.i ], [ %incdec.ptr.i, %if.end.i126 ] + %x.09.i = phi i32 [ 0, %for.body21.lr.ph.i ], [ %inc.i125, %if.end.i126 ] + br i1 undef, label %if.end.i126, label %if.else.i124 + +if.else.i124: ; preds = %for.body21.i + store i8 undef, i8* %destYPixelPtr.010.i, align 1 + br label %if.end.i126 + +if.end.i126: ; preds = %if.else.i124, %for.body21.i + %incdec.ptr.i = getelementptr inbounds i8* %destYPixelPtr.010.i, i32 1 + %inc.i125 = add i32 %x.09.i, 1 + %cmp19.i = icmp ult i32 %inc.i125, undef + br i1 %cmp19.i, label %for.body21.i, label %for.end.i129 + +for.end.i129: ; preds = %if.end.i126, %for.body.i86 + br i1 undef, label %for.body.i86, label %while.cond + +while.end: ; preds = %while.cond + br label %bail + +bail: ; preds = %while.end, %lor.lhs.false44, %lor.lhs.false41, %if.end29, %if.end + unreachable + +return: ; preds = %lor.lhs.false20, %lor.lhs.false12, %lor.lhs.false, %entry + ret void +} diff --git a/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll b/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll new file mode 100644 index 0000000..c0c508f --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll @@ -0,0 +1,140 @@ +; RUN: opt < %s -indvars -S "-default-data-layout=e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" | FileCheck %s +; RUN: opt < %s -indvars -S "-default-data-layout=e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" | FileCheck %s +; +; PR11279: Assertion !IVLimit->getType()->isPointerTy() +; +; Test LinearFunctionTestReplace of a pointer-type loop counter. Note +; that BECount may or may not be a pointer type. A pointer type +; BECount doesn't really make sense, but that's what falls out of +; SCEV. Since it's an i8*, it has unit stride so we never adjust the +; SCEV expression in a way that would convert it to an integer type. + +; CHECK: @testnullptrptr +; CHECK: loop: +; CHECK: icmp ne +define i8 @testnullptrptr(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %guard = icmp ult i8* null, %end + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ null, %preheader ], [ %gep, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %cmp = icmp ult i8* %gep, %end + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; CHECK: @testptrptr +; CHECK: loop: +; CHECK: icmp ne +define i8 @testptrptr(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %guard = icmp ult i8* %buf, %end + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ %buf, %preheader ], [ %gep, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %cmp = icmp ult i8* %gep, %end + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; CHECK: @testnullptrint +; CHECK: loop: +; CHECK: icmp ne +define i8 @testnullptrint(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %bi = ptrtoint i8* %buf to i32 + %ei = ptrtoint i8* %end to i32 + %cnt = sub i32 %ei, %bi + %guard = icmp ult i32 0, %cnt + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ null, %preheader ], [ %gep, %loop ] + %iv = phi i32 [ 0, %preheader ], [ %ivnext, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %ivnext = add i32 %iv, 1 + %cmp = icmp ult i32 %ivnext, %cnt + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; CHECK: @testptrint +; CHECK: loop: +; CHECK: icmp ne +define i8 @testptrint(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %bi = ptrtoint i8* %buf to i32 + %ei = ptrtoint i8* %end to i32 + %cnt = sub i32 %ei, %bi + %guard = icmp ult i32 %bi, %cnt + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ %buf, %preheader ], [ %gep, %loop ] + %iv = phi i32 [ %bi, %preheader ], [ %ivnext, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %ivnext = add i32 %iv, 1 + %cmp = icmp ult i32 %ivnext, %cnt + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; IV and BECount have two different pointer types here. +define void @testnullptr([512 x i8]* %base) nounwind { +entry: + %add.ptr1603 = getelementptr [512 x i8]* %base, i64 0, i64 512 + br label %preheader + +preheader: + %cmp1604192 = icmp ult i8* undef, %add.ptr1603 + br i1 %cmp1604192, label %for.body, label %for.end1609 + +for.body: + %r.17193 = phi i8* [ %incdec.ptr1608, %for.body ], [ null, %preheader ] + %incdec.ptr1608 = getelementptr i8* %r.17193, i64 1 + %cmp1604 = icmp ult i8* %incdec.ptr1608, %add.ptr1603 + br i1 %cmp1604, label %for.body, label %for.end1609 + +for.end1609: + unreachable +} diff --git a/test/Transforms/IndVarSimplify/2011-11-15-multiexit.ll b/test/Transforms/IndVarSimplify/2011-11-15-multiexit.ll new file mode 100644 index 0000000..c74d04e --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-11-15-multiexit.ll @@ -0,0 +1,40 @@ +; RUN: opt < %s -indvars -S | FileCheck %s +; +; Prior to the fix for PR11375, indvars would replace %firstIV with a +; loop-invariant gep computed in the preheader. This was incorrect +; because it was based on the minimum "ExitNotTaken" count. If the +; final loop test is skipped (odd number of elements) then the early +; exit would be taken and the loop invariant value would be incorrect. + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-apple-darwin" + +; CHECK: if.end: +; CHECK: phi i32* [ %first.lcssa, %early.exit ] +define i32 @test(i32* %first, i32* %last) uwtable ssp { +entry: + br i1 undef, label %if.end, label %if.then + +if.then: ; preds = %entry + br i1 undef, label %if.end, label %do.body + +do.body: ; preds = %if.else, %if.then + %firstIV = phi i32* [ %incdec.ptr2, %if.else ], [ %first, %if.then ] + %incdec.ptr1 = getelementptr inbounds i32* %firstIV, i64 1 + %cmp1 = icmp eq i32* %incdec.ptr1, %last + br i1 %cmp1, label %early.exit, label %if.else + +if.else: ; preds = %do.body + %incdec.ptr2 = getelementptr inbounds i32* %firstIV, i64 2 + %cmp2 = icmp eq i32* %incdec.ptr2, %last + br i1 %cmp2, label %if.end, label %do.body + +early.exit: + %first.lcssa = phi i32* [ %firstIV, %do.body ] + br label %if.end + +if.end: + %tmp = phi i32* [ %first.lcssa, %early.exit ], [ %first, %if.then ], [ %first, %entry ], [ undef, %if.else ] + %val = load i32* %tmp + ret i32 %val +} diff --git a/test/Transforms/IndVarSimplify/2011-11-17-selfphi.ll b/test/Transforms/IndVarSimplify/2011-11-17-selfphi.ll new file mode 100644 index 0000000..ccf2595 --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-11-17-selfphi.ll @@ -0,0 +1,29 @@ +; RUN: opt < %s -indvars -S | FileCheck %s +; PR11350: Check that SimplifyIndvar handles a cycle of useless self-phis. + +; CHECK: @test +; CHECK-NOT: lcssa = phi +define void @test() nounwind { +entry: + br label %for.cond.preheader + +for.cond.preheader: ; preds = %entry + br label %for.cond.outer + +for.cond.outer: ; preds = %for.cond.preheader, %for.end + %p_41.addr.0.ph = phi i32 [ %p_41.addr.1.lcssa, %for.end ], [ 1, %for.cond.preheader ] + br label %for.cond + +for.cond: + br i1 true, label %for.end, label %for.ph + +for.ph: ; preds = %for.cond4.preheader + br label %for.end + +for.end: + %p_41.addr.1.lcssa = phi i32 [ undef, %for.ph ], [ %p_41.addr.0.ph, %for.cond ] + %p_68.lobit.i = lshr i32 %p_41.addr.1.lcssa, 31 + %cmp7 = icmp eq i32 %p_41.addr.1.lcssa, 0 + %conv8 = zext i1 %cmp7 to i32 + br label %for.cond.outer +} diff --git a/test/Transforms/IndVarSimplify/ada-loops.ll b/test/Transforms/IndVarSimplify/ada-loops.ll index 154de6f..c093298 100644 --- a/test/Transforms/IndVarSimplify/ada-loops.ll +++ b/test/Transforms/IndVarSimplify/ada-loops.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s ; ; PR1301 diff --git a/test/Transforms/IndVarSimplify/addrec-gep.ll b/test/Transforms/IndVarSimplify/addrec-gep.ll deleted file mode 100644 index b62d093..0000000 --- a/test/Transforms/IndVarSimplify/addrec-gep.ll +++ /dev/null @@ -1,78 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: getelementptr -; CHECK: mul {{.*}}, 37 -; CHECK: add {{.*}}, 5203 -; CHECK-NOT: cast - -; This test tests several things. The load and store should use the -; same address instead of having it computed twice, and SCEVExpander should -; be able to reconstruct the full getelementptr, despite it having a few -; obstacles set in its way. - -target datalayout = "e-p:64:64:64-n32:64" - -define void @foo(i64 %n, i64 %m, i64 %o, i64 %q, double* nocapture %p) nounwind { -entry: - %tmp = icmp sgt i64 %n, 0 ; <i1> [#uses=1] - br i1 %tmp, label %bb.nph3, label %return - -bb.nph: ; preds = %bb2.preheader - %tmp1 = mul i64 %tmp16, %i.02 ; <i64> [#uses=1] - %tmp2 = mul i64 %tmp19, %i.02 ; <i64> [#uses=1] - br label %bb1 - -bb1: ; preds = %bb2, %bb.nph - %j.01 = phi i64 [ %tmp9, %bb2 ], [ 0, %bb.nph ] ; <i64> [#uses=3] - %tmp3 = add i64 %j.01, %tmp1 ; <i64> [#uses=1] - %tmp4 = add i64 %j.01, %tmp2 ; <i64> [#uses=1] - %z0 = add i64 %tmp3, 5203 - %tmp5 = getelementptr double* %p, i64 %z0 ; <double*> [#uses=1] - %tmp6 = load double* %tmp5, align 8 ; <double> [#uses=1] - %tmp7 = fdiv double %tmp6, 2.100000e+00 ; <double> [#uses=1] - %z1 = add i64 %tmp4, 5203 - %tmp8 = getelementptr double* %p, i64 %z1 ; <double*> [#uses=1] - store double %tmp7, double* %tmp8, align 8 - %tmp9 = add i64 %j.01, 1 ; <i64> [#uses=2] - br label %bb2 - -bb2: ; preds = %bb1 - %tmp10 = icmp slt i64 %tmp9, %m ; <i1> [#uses=1] - br i1 %tmp10, label %bb1, label %bb2.bb3_crit_edge - -bb2.bb3_crit_edge: ; preds = %bb2 - br label %bb3 - -bb3: ; preds = %bb2.preheader, %bb2.bb3_crit_edge - %tmp11 = add i64 %i.02, 1 ; <i64> [#uses=2] - br label %bb4 - -bb4: ; preds = %bb3 - %tmp12 = icmp slt i64 %tmp11, %n ; <i1> [#uses=1] - br i1 %tmp12, label %bb2.preheader, label %bb4.return_crit_edge - -bb4.return_crit_edge: ; preds = %bb4 - br label %bb4.return_crit_edge.split - -bb4.return_crit_edge.split: ; preds = %bb.nph3, %bb4.return_crit_edge - br label %return - -bb.nph3: ; preds = %entry - %tmp13 = icmp sgt i64 %m, 0 ; <i1> [#uses=1] - %tmp14 = mul i64 %n, 37 ; <i64> [#uses=1] - %tmp15 = mul i64 %tmp14, %o ; <i64> [#uses=1] - %tmp16 = mul i64 %tmp15, %q ; <i64> [#uses=1] - %tmp17 = mul i64 %n, 37 ; <i64> [#uses=1] - %tmp18 = mul i64 %tmp17, %o ; <i64> [#uses=1] - %tmp19 = mul i64 %tmp18, %q ; <i64> [#uses=1] - br i1 %tmp13, label %bb.nph3.split, label %bb4.return_crit_edge.split - -bb.nph3.split: ; preds = %bb.nph3 - br label %bb2.preheader - -bb2.preheader: ; preds = %bb.nph3.split, %bb4 - %i.02 = phi i64 [ %tmp11, %bb4 ], [ 0, %bb.nph3.split ] ; <i64> [#uses=3] - br i1 true, label %bb.nph, label %bb3 - -return: ; preds = %bb4.return_crit_edge.split, %entry - ret void -} diff --git a/test/Transforms/IndVarSimplify/avoid-i0.ll b/test/Transforms/IndVarSimplify/avoid-i0.ll index 59661fa..22f2e4b 100644 --- a/test/Transforms/IndVarSimplify/avoid-i0.ll +++ b/test/Transforms/IndVarSimplify/avoid-i0.ll @@ -90,7 +90,7 @@ entry: br label %bb4 bb: ; preds = %bb4 - %0 = volatile load i32* @x, align 4 ; <i32> [#uses=1] + %0 = load volatile i32* @x, align 4 ; <i32> [#uses=1] store i32 %0, i32* %vol.0, align 4 store i32 0, i32* %l_52, align 4 br label %bb2 diff --git a/test/Transforms/IndVarSimplify/complex-scev.ll b/test/Transforms/IndVarSimplify/complex-scev.ll deleted file mode 100644 index 395377e..0000000 --- a/test/Transforms/IndVarSimplify/complex-scev.ll +++ /dev/null @@ -1,31 +0,0 @@ -; The i induction variable looks like a wrap-around, but it really is just -; a simple affine IV. Make sure that indvars eliminates it. - -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: phi -; CHECK-NOT: phi - -define void @foo() { -entry: - br label %bb6 - -bb6: ; preds = %cond_true, %entry - %j.0 = phi i32 [ 1, %entry ], [ %tmp5, %cond_true ] ; <i32> [#uses=3] - %i.0 = phi i32 [ 0, %entry ], [ %j.0, %cond_true ] ; <i32> [#uses=1] - %tmp7 = call i32 (...)* @foo2( ) ; <i32> [#uses=1] - %tmp = icmp ne i32 %tmp7, 0 ; <i1> [#uses=1] - br i1 %tmp, label %cond_true, label %return - -cond_true: ; preds = %bb6 - %tmp2 = call i32 (...)* @bar( i32 %i.0, i32 %j.0 ) ; <i32> [#uses=0] - %tmp5 = add i32 %j.0, 1 ; <i32> [#uses=1] - br label %bb6 - -return: ; preds = %bb6 - ret void -} - -declare i32 @bar(...) - -declare i32 @foo2(...) - diff --git a/test/Transforms/IndVarSimplify/dg.exp b/test/Transforms/IndVarSimplify/dg.exp deleted file mode 100644 index f200589..0000000 --- a/test/Transforms/IndVarSimplify/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/IndVarSimplify/elim-extend.ll b/test/Transforms/IndVarSimplify/elim-extend.ll index 43c162f..ad5679f 100644 --- a/test/Transforms/IndVarSimplify/elim-extend.ll +++ b/test/Transforms/IndVarSimplify/elim-extend.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" diff --git a/test/Transforms/IndVarSimplify/gep-with-mul-base.ll b/test/Transforms/IndVarSimplify/gep-with-mul-base.ll deleted file mode 100644 index 7e1e2a3..0000000 --- a/test/Transforms/IndVarSimplify/gep-with-mul-base.ll +++ /dev/null @@ -1,68 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: define void @foo -; CHECK: mul -; CHECK: mul -; CHECK: mul -; CHECK: add -; CHECK: sub -; CHECK: define void @bar -; CHECK: mul -; CHECK: mul -; CHECK: mul -; CHECK: add -; CHECK: sub - -define void @foo(i64 %n, i64 %m, i64 %o, double* nocapture %p) nounwind { -entry: - %tmp = icmp sgt i64 %n, 0 ; <i1> [#uses=1] - br i1 %tmp, label %bb.nph, label %return - -bb.nph: ; preds = %entry - %tmp1 = mul i64 %n, 37 ; <i64> [#uses=1] - %tmp2 = mul i64 %tmp1, %m ; <i64> [#uses=1] - %tmp3 = mul i64 %tmp2, %o ; <i64> [#uses=1] - br label %bb - -bb: ; preds = %bb, %bb.nph - %i.01 = phi i64 [ %tmp3, %bb.nph ], [ %tmp13, %bb ] ; <i64> [#uses=3] - %tmp9 = getelementptr double* %p, i64 %i.01 ; <double*> [#uses=1] - %tmp10 = load double* %tmp9, align 8 ; <double> [#uses=1] - %tmp11 = fdiv double %tmp10, 2.100000e+00 ; <double> [#uses=1] - store double %tmp11, double* %tmp9, align 8 - %tmp13 = add i64 %i.01, 1 ; <i64> [#uses=2] - %tmp14 = icmp slt i64 %tmp13, %n ; <i1> [#uses=1] - br i1 %tmp14, label %bb, label %return.loopexit - -return.loopexit: ; preds = %bb - br label %return - -return: ; preds = %return.loopexit, %entry - ret void -} -define void @bar(i64 %n, i64 %m, i64 %o, i64 %q, double* nocapture %p) nounwind { -entry: - %tmp = icmp sgt i64 %n, 0 ; <i1> [#uses=1] - br i1 %tmp, label %bb.nph, label %return - -bb.nph: ; preds = %entry - %tmp1 = mul i64 %n, %q ; <i64> [#uses=1] - %tmp2 = mul i64 %tmp1, %m ; <i64> [#uses=1] - %tmp3 = mul i64 %tmp2, %o ; <i64> [#uses=1] - br label %bb - -bb: ; preds = %bb, %bb.nph - %i.01 = phi i64 [ %tmp3, %bb.nph ], [ %tmp13, %bb ] ; <i64> [#uses=3] - %tmp9 = getelementptr double* %p, i64 %i.01 ; <double*> [#uses=1] - %tmp10 = load double* %tmp9, align 8 ; <double> [#uses=1] - %tmp11 = fdiv double %tmp10, 2.100000e+00 ; <double> [#uses=1] - store double %tmp11, double* %tmp9, align 8 - %tmp13 = add i64 %i.01, 1 ; <i64> [#uses=2] - %tmp14 = icmp slt i64 %tmp13, %n ; <i1> [#uses=1] - br i1 %tmp14, label %bb, label %return.loopexit - -return.loopexit: ; preds = %bb - br label %return - -return: ; preds = %return.loopexit, %entry - ret void -} diff --git a/test/Transforms/IndVarSimplify/iv-fold.ll b/test/Transforms/IndVarSimplify/iv-fold.ll index 2e19118..e0b05cd 100644 --- a/test/Transforms/IndVarSimplify/iv-fold.ll +++ b/test/Transforms/IndVarSimplify/iv-fold.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n32:64" diff --git a/test/Transforms/IndVarSimplify/iv-zext.ll b/test/Transforms/IndVarSimplify/iv-zext.ll index 646e6c0..2e0f70c 100644 --- a/test/Transforms/IndVarSimplify/iv-zext.ll +++ b/test/Transforms/IndVarSimplify/iv-zext.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s ; CHECK-NOT: and ; CHECK-NOT: zext diff --git a/test/Transforms/IndVarSimplify/lftr-reuse.ll b/test/Transforms/IndVarSimplify/lftr-reuse.ll index 490eee9..9abfe13 100644 --- a/test/Transforms/IndVarSimplify/lftr-reuse.ll +++ b/test/Transforms/IndVarSimplify/lftr-reuse.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s ; ; Make sure that indvars can perform LFTR without a canonical IV. diff --git a/test/Transforms/IndVarSimplify/lit.local.cfg b/test/Transforms/IndVarSimplify/lit.local.cfg new file mode 100644 index 0000000..19eebc0 --- /dev/null +++ b/test/Transforms/IndVarSimplify/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/IndVarSimplify/loop_evaluate10.ll b/test/Transforms/IndVarSimplify/loop_evaluate10.ll index 269478a..c3619f6 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate10.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate10.ll @@ -1,8 +1,14 @@ ; RUN: opt < %s -indvars -S \ ; RUN: | grep {%b.1 = phi i32 \\\[ 2, %bb \\\], \\\[ 1, %bb2 \\\]} - +; ; This loop has multiple exits, and the value of %b1 depends on which ; exit is taken. Indvars should correctly compute the exit values. +; +; XFAIL: * +; Indvars does not currently replace loop invariant values unless all +; loop exits have the same exit value. We could handle some cases, +; such as this, by making getSCEVAtScope() sensitive to a particular +; loop exit. See PR11388. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" target triple = "x86_64-pc-linux-gnu" diff --git a/test/Transforms/IndVarSimplify/loop_evaluate9.ll b/test/Transforms/IndVarSimplify/loop_evaluate9.ll index 8184a73..9f3bcaf 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate9.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate9.ll @@ -2,8 +2,13 @@ ; RUN: grep {\[%\]tmp7 = icmp eq i8 -28, -28} %t ; RUN: grep {\[%\]tmp8 = icmp eq i8 63, 63} %t ; PR4477 - ; Indvars should compute the exit values in loop. +; +; XFAIL: * +; Indvars does not currently replace loop invariant values unless all +; loop exits have the same exit value. We could handle some cases, +; such as this, by making getSCEVAtScope() sensitive to a particular +; loop exit. See PR11388. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32" target triple = "i386-pc-linux-gnu" diff --git a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll index 9c2abd0..bfdd000 100644 --- a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll +++ b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s ; ; Make sure that indvars isn't inserting canonical IVs. ; This is kinda hard to do until linear function test replacement is removed. @@ -333,9 +333,9 @@ entry: ; CHECK: loop: ; CHECK: phi %structIF* -; CHECK: phi i32* -; CHECK: getelementptr inbounds +; CHECK-NOT: phi ; CHECK: getelementptr inbounds +; CHECK-NOT: getelementptr ; CHECK: exit: loop: %ptr.iv = phi %structIF* [ %ptr.inc, %latch ], [ %base, %entry ] diff --git a/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll b/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll deleted file mode 100644 index 251d34e..0000000 --- a/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll +++ /dev/null @@ -1,42 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK-NOT: {{inttoptr|ptrtoint}} -; CHECK: scevgep -; CHECK-NOT: {{inttoptr|ptrtoint}} -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n32:64" - -; Indvars shouldn't need inttoptr/ptrtoint to expand an address here. - -define void @foo(i8* %p) nounwind { -entry: - br i1 true, label %bb.nph, label %for.end - -for.cond: - %phitmp = icmp slt i64 %inc, 20 - br i1 %phitmp, label %for.body, label %for.cond.for.end_crit_edge - -for.cond.for.end_crit_edge: - br label %for.end - -bb.nph: - br label %for.body - -for.body: - %storemerge1 = phi i64 [ %inc, %for.cond ], [ 0, %bb.nph ] - %call = tail call i64 @bar() nounwind - %call2 = tail call i64 @car() nounwind - %conv = trunc i64 %call2 to i8 - %conv3 = sext i8 %conv to i64 - %add = add nsw i64 %call, %storemerge1 - %add4 = add nsw i64 %add, %conv3 - %arrayidx = getelementptr inbounds i8* %p, i64 %add4 - store i8 0, i8* %arrayidx - %inc = add nsw i64 %storemerge1, 1 - br label %for.cond - -for.end: - ret void -} - -declare i64 @bar() - -declare i64 @car() diff --git a/test/Transforms/IndVarSimplify/preserve-gep-nested.ll b/test/Transforms/IndVarSimplify/preserve-gep-nested.ll deleted file mode 100644 index cdcaaa0..0000000 --- a/test/Transforms/IndVarSimplify/preserve-gep-nested.ll +++ /dev/null @@ -1,76 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; No explicit integer multiplications! -; No i8* arithmetic or pointer casting anywhere! -; CHECK-NOT: = {{= mul|i8\*|bitcast|inttoptr|ptrtoint}} -; Exactly one getelementptr for each load+store. -; Each getelementptr using %struct.Q* %s as a base and not i8*. -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK-NOT: = {{= mul|i8\*|bitcast|inttoptr|ptrtoint}} - -; FIXME: This test should pass with or without TargetData. Until opt -; supports running tests without targetdata, just hardware this in. -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n32:64" - -%struct.Q = type { [10 x %struct.N] } -%struct.N = type { %struct.S } -%struct.S = type { [100 x double], [100 x double] } - -define void @foo(%struct.Q* %s, i64 %n) nounwind { -entry: - br label %bb1 - -bb1: - %i = phi i64 [ 2, %entry ], [ %i.next, %bb ] - %j = phi i64 [ 0, %entry ], [ %j.next, %bb ] - %t5 = icmp slt i64 %i, %n - br i1 %t5, label %bb, label %return - -bb: - %t0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %i - %t1 = load double* %t0, align 8 - %t2 = fmul double %t1, 3.200000e+00 - %t3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %i - store double %t2, double* %t3, align 8 - - %s0 = getelementptr inbounds %struct.Q* %s, i64 13, i32 0, i64 7, i32 0, i32 1, i64 %i - %s1 = load double* %s0, align 8 - %s2 = fmul double %s1, 3.200000e+00 - %s3 = getelementptr inbounds %struct.Q* %s, i64 13, i32 0, i64 7, i32 0, i32 1, i64 %i - store double %s2, double* %s3, align 8 - - %u0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 7, i32 0, i32 1, i64 %j - %u1 = load double* %u0, align 8 - %u2 = fmul double %u1, 3.200000e+00 - %u3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 7, i32 0, i32 1, i64 %j - store double %u2, double* %u3, align 8 - - %v0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 1, i64 %i - %v1 = load double* %v0, align 8 - %v2 = fmul double %v1, 3.200000e+00 - %v3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 1, i64 %i - store double %v2, double* %v3, align 8 - - %w0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %j - %w1 = load double* %w0, align 8 - %w2 = fmul double %w1, 3.200000e+00 - %w3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %j - store double %w2, double* %w3, align 8 - - %x0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 3, i32 0, i32 0, i64 %i - %x1 = load double* %x0, align 8 - %x2 = fmul double %x1, 3.200000e+00 - %x3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 3, i32 0, i32 0, i64 %i - store double %x2, double* %x3, align 8 - - %i.next = add i64 %i, 1 - %j.next = add i64 %j, 1 - br label %bb1 - -return: - ret void -} diff --git a/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll b/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll deleted file mode 100644 index 2f3100f..0000000 --- a/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll +++ /dev/null @@ -1,20 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %0, i64 1 -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n32:64" - -; Indvars shouldn't expand this to -; %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19 -; or something. That's valid, but more obscure. - -define void @foo([3 x [3 x double]]* noalias %p) nounwind { -entry: - br label %loop - -loop: - %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] - %ip = add i64 %i, 1 - %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %ip, i64 1 - volatile store double 0.0, double* %p.2.ip.1 - %i.next = add i64 %i, 1 - br label %loop -} diff --git a/test/Transforms/IndVarSimplify/preserve-gep.ll b/test/Transforms/IndVarSimplify/preserve-gep.ll deleted file mode 100644 index fec8a28..0000000 --- a/test/Transforms/IndVarSimplify/preserve-gep.ll +++ /dev/null @@ -1,39 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK-NOT: {{ptrtoint|inttoptr}} -; CHECK: getelementptr -; CHECK-NOT: {{ptrtoint|inttoptr|getelementptr}} - -; Indvars shouldn't leave getelementptrs expanded out as -; inttoptr+ptrtoint in its output in common cases. - -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n32:64" -target triple = "x86_64-unknown-linux-gnu" - %struct.Foo = type { i32, i32, [10 x i32], i32 } - -define void @me(%struct.Foo* nocapture %Bar) nounwind { -entry: - br i1 false, label %return, label %bb.nph - -bb.nph: ; preds = %entry - br label %bb - -bb: ; preds = %bb1, %bb.nph - %i.01 = phi i64 [ %4, %bb1 ], [ 0, %bb.nph ] ; <i64> [#uses=3] - %0 = getelementptr %struct.Foo* %Bar, i64 %i.01, i32 2, i64 3 ; <i32*> [#uses=1] - %1 = load i32* %0, align 4 ; <i32> [#uses=1] - %2 = mul i32 %1, 113 ; <i32> [#uses=1] - %3 = getelementptr %struct.Foo* %Bar, i64 %i.01, i32 2, i64 3 ; <i32*> [#uses=1] - store i32 %2, i32* %3, align 4 - %4 = add i64 %i.01, 1 ; <i64> [#uses=2] - br label %bb1 - -bb1: ; preds = %bb - %phitmp = icmp sgt i64 %4, 19999 ; <i1> [#uses=1] - br i1 %phitmp, label %bb1.return_crit_edge, label %bb - -bb1.return_crit_edge: ; preds = %bb1 - br label %return - -return: ; preds = %bb1.return_crit_edge, %entry - ret void -} diff --git a/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll b/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll index 22e2092..f619e8d 100644 --- a/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll +++ b/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s ; Indvars should insert a 64-bit induction variable to eliminate the ; sext for the addressing, however it shouldn't eliminate the sext diff --git a/test/Transforms/IndVarSimplify/sink-alloca.ll b/test/Transforms/IndVarSimplify/sink-alloca.ll index 3a6c683..64207d8 100644 --- a/test/Transforms/IndVarSimplify/sink-alloca.ll +++ b/test/Transforms/IndVarSimplify/sink-alloca.ll @@ -1,15 +1,10 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; PR4775 - -; Indvars shouldn't sink the alloca out of the entry block, even though -; it's not used until after the loop. - target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin10.0" -@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @main to i8*)], -section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] - +; PR4775 +; Indvars shouldn't sink the alloca out of the entry block, even though +; it's not used until after the loop. define i32 @main() nounwind { ; CHECK: entry: ; CHECK-NEXT: %result.i = alloca i32, align 4 @@ -23,9 +18,39 @@ while.cond: ; preds = %while.cond, %entry br i1 %tobool, label %while.end, label %while.cond while.end: ; preds = %while.cond - volatile store i32 0, i32* %result.i - %tmp.i = volatile load i32* %result.i ; <i32> [#uses=0] + store volatile i32 0, i32* %result.i + %tmp.i = load volatile i32* %result.i ; <i32> [#uses=0] ret i32 0 } - declare i32 @bar() + +; <rdar://problem/10352360> +; Indvars shouldn't sink the first alloca between the stacksave and stackrestore +; intrinsics. +declare i8* @a(...) +declare i8* @llvm.stacksave() nounwind +declare void @llvm.stackrestore(i8*) nounwind +define void @h(i64 %n) nounwind uwtable ssp { +; CHECK: entry: +; CHECK-NEXT: %vla = alloca i8* +; CHECK-NEXT: %savedstack = call i8* @llvm.stacksave() +entry: + %vla = alloca i8*, i64 %n, align 16 + %savedstack = call i8* @llvm.stacksave() nounwind + %vla.i = alloca i8*, i64 %n, align 16 + br label %for.body.i + +for.body.i: + %indvars.iv37.i = phi i64 [ %indvars.iv.next38.i, %for.body.i ], [ 0, %entry ] + %call.i = call i8* (...)* @a() nounwind + %arrayidx.i = getelementptr inbounds i8** %vla.i, i64 %indvars.iv37.i + store i8* %call.i, i8** %arrayidx.i, align 8 + %indvars.iv.next38.i = add i64 %indvars.iv37.i, 1 + %exitcond5 = icmp eq i64 %indvars.iv.next38.i, %n + br i1 %exitcond5, label %g.exit, label %for.body.i + +g.exit: + call void @llvm.stackrestore(i8* %savedstack) nounwind + %call1 = call i8* (...)* @a(i8** %vla) nounwind + ret void +} diff --git a/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll b/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll index fc906cd..fb9ef22 100644 --- a/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll +++ b/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -instcombine -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -instcombine -S | FileCheck %s ; ; Test that -indvars can reduce variable stride IVs. If it can reduce variable ; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without |