[llvm] r230929 - Revert r230921, "Revert some changes that were made to fix PR20680.", for now.
Sanjoy Das
sanjoy at playingwithpointers.com
Mon Mar 2 00:10:40 PST 2015
Thanks for reverting this! I think I know what the issue is, and I'll
fix the test case when I re-land r230921.
As an aside, something that completely threw me off when investigating
this: if you look at the buildbot console (https://imgur.com/ewEp2Ch),
it looks like the bots went green on 230924 and 230926. This before
your change r230929, and I took this to suggest a flaky /
misconfigured buildbot since the failure went away on its own without
actually having to revert r230921.
On closer investigation (also known as "clicking on the green thing")
later, I noticed that the build that is advertised as r230925 on the
console is actually a build of r230929 (https://imgur.com/BfFW097). I
don't know if this is expected behavior, but I find this very
counter-intuitive.
-- Sanjoy
On Sun, Mar 1, 2015 at 5:14 PM, NAKAMURA Takumi <geek4civic at gmail.com> wrote:
> Author: chapuni
> Date: Sun Mar 1 19:14:03 2015
> New Revision: 230929
>
> URL: http://llvm.org/viewvc/llvm-project?rev=230929&view=rev
> Log:
> Revert r230921, "Revert some changes that were made to fix PR20680.", for now.
>
> It caused a failure on clang/test/Misc/backend-optimization-failure.cpp .
>
> Modified:
> llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
> llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll
> llvm/trunk/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll
> llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll
>
> Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=230929&r1=230928&r2=230929&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Sun Mar 1 19:14:03 2015
> @@ -1705,15 +1705,51 @@ LinearFunctionTestReplace(Loop *L,
> // compare against the post-incremented value, otherwise we must compare
> // against the preincremented value.
> if (L->getExitingBlock() == L->getLoopLatch()) {
> - // Add one to the "backedge-taken" count to get the trip count.
> - // This addition may overflow, which is valid as long as the comparison is
> - // truncated to BackedgeTakenCount->getType().
> - IVCount = SE->getAddExpr(BackedgeTakenCount,
> - SE->getConstant(BackedgeTakenCount->getType(), 1));
> // The BackedgeTaken expression contains the number of times that the
> // backedge branches to the loop header. This is one less than the
> // number of times the loop executes, so use the incremented indvar.
> - CmpIndVar = IndVar->getIncomingValueForBlock(L->getExitingBlock());
> + llvm::Value *IncrementedIndvar =
> + IndVar->getIncomingValueForBlock(L->getExitingBlock());
> + const auto *IncrementedIndvarSCEV =
> + cast<SCEVAddRecExpr>(SE->getSCEV(IncrementedIndvar));
> + // It is unsafe to use the incremented indvar if it has a wrapping flag, we
> + // don't want to compare against a poison value. Check the SCEV that
> + // corresponds to the incremented indvar, the SCEVExpander will only insert
> + // flags in the IR if the SCEV originally had wrapping flags.
> + // FIXME: In theory, SCEV could drop flags even though they exist in IR.
> + // A more robust solution would involve getting a new expression for
> + // CmpIndVar by applying non-NSW/NUW AddExprs.
> + auto WrappingFlags =
> + ScalarEvolution::setFlags(SCEV::FlagNUW, SCEV::FlagNSW);
> + const SCEV *IVInit = IncrementedIndvarSCEV->getStart();
> + if (SE->getTypeSizeInBits(IVInit->getType()) >
> + SE->getTypeSizeInBits(IVCount->getType()))
> + IVInit = SE->getTruncateExpr(IVInit, IVCount->getType());
> + unsigned BitWidth = SE->getTypeSizeInBits(IVCount->getType());
> + Type *WideTy = IntegerType::get(SE->getContext(), BitWidth + 1);
> + // Check if InitIV + BECount+1 requires sign/zero extension.
> + // If not, clear the corresponding flag from WrappingFlags because it is not
> + // necessary for those flags in the IncrementedIndvarSCEV expression.
> + if (SE->getSignExtendExpr(SE->getAddExpr(IVInit, BackedgeTakenCount),
> + WideTy) ==
> + SE->getAddExpr(SE->getSignExtendExpr(IVInit, WideTy),
> + SE->getSignExtendExpr(BackedgeTakenCount, WideTy)))
> + WrappingFlags = ScalarEvolution::clearFlags(WrappingFlags, SCEV::FlagNSW);
> + if (SE->getZeroExtendExpr(SE->getAddExpr(IVInit, BackedgeTakenCount),
> + WideTy) ==
> + SE->getAddExpr(SE->getZeroExtendExpr(IVInit, WideTy),
> + SE->getZeroExtendExpr(BackedgeTakenCount, WideTy)))
> + WrappingFlags = ScalarEvolution::clearFlags(WrappingFlags, SCEV::FlagNUW);
> + if (!ScalarEvolution::maskFlags(IncrementedIndvarSCEV->getNoWrapFlags(),
> + WrappingFlags)) {
> + // Add one to the "backedge-taken" count to get the trip count.
> + // This addition may overflow, which is valid as long as the comparison is
> + // truncated to BackedgeTakenCount->getType().
> + IVCount =
> + SE->getAddExpr(BackedgeTakenCount,
> + SE->getConstant(BackedgeTakenCount->getType(), 1));
> + CmpIndVar = IncrementedIndvar;
> + }
> }
>
> Value *ExitCnt = genLoopLimit(IndVar, IVCount, L, Rewriter, SE);
>
> Modified: llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll?rev=230929&r1=230928&r2=230929&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll (original)
> +++ llvm/trunk/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll Sun Mar 1 19:14:03 2015
> @@ -6,7 +6,7 @@ target triple = "thumbv7-apple-darwin"
>
> ; CHECK-LABEL: @test(
> ; CHECK: if.end.i126:
> -; CHECK: %exitcond = icmp ne i8* %incdec.ptr.i, getelementptr (i8* null, i32 undef)
> +; CHECK: %exitcond = icmp ne i8* %destYPixelPtr.010.i, getelementptr (i8* null, i32 undef)
> define void @test() nounwind {
> entry:
> br label %while.cond
>
> Modified: llvm/trunk/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll?rev=230929&r1=230928&r2=230929&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll (original)
> +++ llvm/trunk/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll Sun Mar 1 19:14:03 2015
> @@ -11,7 +11,7 @@ entry:
> br i1 %cmp1, label %for.body, label %for.end
>
> ; Make sure the added GEP has the right index type
> -; CHECK: %lftr.limit = getelementptr i8, i8 addrspace(2)* %base, i8 %0
> +; CHECK: %lftr.limit = getelementptr i8, i8 addrspace(2)* %base, i8
>
> ; CHECK: for.body:
> ; CHECK: phi i8 addrspace(2)*
> @@ -43,7 +43,7 @@ entry:
> br i1 %cmp1, label %for.body, label %for.end
>
> ; Make sure the added GEP has the right index type
> -; CHECK: %lftr.limit = getelementptr i8, i8 addrspace(3)* %base, i16 %0
> +; CHECK: %lftr.limit = getelementptr i8, i8 addrspace(3)* %base, i16
>
> ; CHECK: for.body:
> ; CHECK: phi i8 addrspace(3)*
>
> Modified: llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll?rev=230929&r1=230928&r2=230929&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll (original)
> +++ llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll Sun Mar 1 19:14:03 2015
> @@ -82,15 +82,23 @@ exit:
> ; Perform LFTR without generating extra preheader code.
> define void @guardedloop([0 x double]* %matrix, [0 x double]* %vector,
> i32 %irow, i32 %ilead) nounwind {
> -; CHECK: entry:
> -; CHECK-NOT: zext
> -; CHECK-NOT: add
> -; CHECK: loop:
> -; CHECK: phi i64
> -; CHECK: phi i64
> +; CHECK-LABEL: @guardedloop(
> +; CHECK-LABEL: entry:
> +; CHECK-NEXT: %[[cmp:.*]] = icmp slt i32 1, %irow
> +; CHECK-NEXT: br i1 %[[cmp]], label %[[loop_preheader:.*]], label %[[return:.*]]
> +
> +; CHECK: [[loop_preheader]]:
> +; CHECK-NEXT: %[[sext:.*]] = sext i32 %ilead to i64
> +; CHECK-NEXT: %[[add:.*]] = add i32 %irow, -1
> +; CHECK-NEXT: br label %[[loop:.*]]
> +
> +; CHECK: [[loop]]:
> +; CHECK-NEXT: %[[indvars_iv2:.*]] = phi i64
> +; CHECK-NEXT: phi i64
> ; CHECK-NOT: phi
> -; CHECK: icmp ne
> -; CHECK: br i1
> +; CHECK: %[[lftr_wideiv:.*]] = trunc i64 %[[indvars_iv2]] to i32
> +; CHECK-NEXT: %[[exitcond:.*]] = icmp ne i32 %[[lftr_wideiv]], %[[add]]
> +; CHECK-NEXT: br i1 %[[exitcond]], label %[[loop]], label
> entry:
> %cmp = icmp slt i32 1, %irow
> br i1 %cmp, label %loop, label %return
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list