summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-07-08 17:18:32 +0000
committerChris Lattner <sabre@nondot.org>2008-07-08 17:18:32 +0000
commit501d78fdc00d8e582f4296a3fd484c95d7b42f60 (patch)
treee357f6fe80a806d47bea0bb92c9d5fbc7ae4057d /llvm/lib
parent855d2c38ec5d4ef13b6778b21ab55729b747da7d (diff)
downloadbcm5719-llvm-501d78fdc00d8e582f4296a3fd484c95d7b42f60.tar.gz
bcm5719-llvm-501d78fdc00d8e582f4296a3fd484c95d7b42f60.zip
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 llvm-svn: 53240
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 8bc909196af..f8ad98c5170 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud