[llvm] r288725 - [SCCP] Remove manual folding of terminator instructions.

David L. Jones via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 18:33:39 PST 2016


It looks like this is breaking several tests, and may be the cause 
of https://llvm.org/bugs/show_bug.cgi?id=31271.

I see these failures starting with this commit:

Failing Tests (10):
    LLVM :: Transforms/IPConstantProp/fp-bc-icmp-const-fold.ll
    LLVM :: Transforms/IPConstantProp/global.ll
    LLVM :: Transforms/IPConstantProp/user-with-multiple-uses.ll
    LLVM :: Transforms/SCCP/apint-ipsccp1.ll
    LLVM :: Transforms/SCCP/apint-ipsccp2.ll
    LLVM :: Transforms/SCCP/apint-ipsccp3.ll
    LLVM :: Transforms/SCCP/apint-ipsccp4.ll
    LLVM :: Transforms/SCCP/atomic-load-store.ll
    LLVM :: Transforms/SCCP/ipsccp-basic.ll
    LLVM :: Transforms/SCCP/switch-multiple-undef.ll


Do you have a fix in mind? If not, could you try rolling back the change?


On Monday, December 5, 2016 at 3:14:34 PM UTC-8, Davide Italiano via 
llvm-commits wrote:
>
> Author: davide
> Date: Mon Dec  5 17:04:21 2016
> New Revision: 288725
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288725&view=rev
> Log:
> [SCCP] Remove manual folding of terminator instructions.
>
> There are two cases handled here:
> 1) a branch on undef
> 2) a switch with an undef condition.
>
> Both cases are currently handled by ResolvedUndefsIn. If we have
> a branch on undef, we force its value to false (which is trivially
> foldable). If we have a switch on undef, we force to the first
> constant (which is also foldable).
>
> Modified:
>     llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=288725&r1=288724&r2=288725&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Mon Dec  5 17:04:21 2016
> @@ -1828,33 +1828,8 @@ static bool runIPSCCP(Module &M, const D
>          // Ignore blockaddress users; BasicBlock's dtor will handle them.
>          if (!I) continue;
>  
> -        bool Folded = ConstantFoldTerminator(I->getParent());
> -        if (!Folded) {
> -          // The constant folder may not have been able to fold the 
> terminator
> -          // if this is a branch or switch on undef.  Fold it manually as 
> a
> -          // branch to the first successor.
> -#ifndef NDEBUG
> -          if (auto *BI = dyn_cast<BranchInst>(I)) {
> -            assert(BI->isConditional() && 
> isa<UndefValue>(BI->getCondition()) &&
> -                   "Branch should be foldable!");
> -          } else if (auto *SI = dyn_cast<SwitchInst>(I)) {
> -            assert(isa<UndefValue>(SI->getCondition()) && "Switch should 
> fold");
> -          } else {
> -            llvm_unreachable("Didn't fold away reference to block!");
> -          }
> -#endif
> -
> -          // Make this an uncond branch to the first successor.
> -          TerminatorInst *TI = I->getParent()->getTerminator();
> -          BranchInst::Create(TI->getSuccessor(0), TI);
> -
> -          // Remove entries in successor phi nodes to remove edges.
> -          for (unsigned i = 1, e = TI->getNumSuccessors(); i != e; ++i)
> -            TI->getSuccessor(i)->removePredecessor(TI->getParent());
> -
> -          // Remove the old terminator.
> -          TI->eraseFromParent();
> -        }
> +        assert(ConstantFoldTerminator(I->getParent()) &&
> +          "Terminator should've been folded");
>        }
>  
>        // Finally, delete the basic block.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161205/181bf784/attachment.html>


More information about the llvm-commits mailing list