diff options
author | Chris Lattner <sabre@nondot.org> | 2008-07-08 17:18:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-07-08 17:18:32 +0000 |
commit | 710429645ac0327dbe83ceab040fe04d2cfff605 (patch) | |
tree | 8f4c6b4d8d2a82cc9d37a2c279e85e222e2bbd97 /lib/Transforms | |
parent | 895860e27ba65383de0f3301cd2b93cbaf5ea538 (diff) |
Fix PR2496, a really nasty bug which involved sinking volatile loads
into phis. This is actually the same bug as PR2262 /
2008-04-29-VolatileLoadDontMerge.ll, but I missed checking the first
predecessor for multiple successors. Testcase here:
InstCombine/2008-07-08-VolatileLoadMerge.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53240 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 8bc909196a..f8ad98c517 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -9354,6 +9354,14 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) { if (LI->getParent() != PN.getIncomingBlock(0) || !isSafeToSinkLoad(LI)) return 0; + + // If the PHI is of volatile loads and the load block has multiple + // successors, sinking it would remove a load of the volatile value from + // the path through the other successor. + if (isVolatile && + LI->getParent()->getTerminator()->getNumSuccessors() != 1) + return 0; + } else if (isa<GetElementPtrInst>(FirstInst)) { if (FirstInst->getNumOperands() == 2) return FoldPHIArgBinOpIntoPHI(PN); @@ -9380,9 +9388,9 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) { !isSafeToSinkLoad(LI)) return 0; - // If the PHI is volatile and its block has multiple successors, sinking - // it would remove a load of the volatile value from the path through the - // other successor. + // If the PHI is of volatile loads and the load block has multiple + // successors, sinking it would remove a load of the volatile value from + // the path through the other successor. if (isVolatile && LI->getParent()->getTerminator()->getNumSuccessors() != 1) return 0; |