diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-11-01 04:49:29 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-11-01 04:49:29 +0000 |
commit | a49b828f8fe1f50d23bf177cf019610e938c336b (patch) | |
tree | 692233024dc72c179314a0ea5970ea6934e26429 /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | |
parent | 86fe42d1844a3c51866a16b560c7a0028a30ed73 (diff) | |
download | bcm5719-llvm-a49b828f8fe1f50d23bf177cf019610e938c336b.tar.gz bcm5719-llvm-a49b828f8fe1f50d23bf177cf019610e938c336b.zip |
Make sure we use the right insertion point when instcombine replaces a PHI with another instruction. (Specifically, don't insert an arbitrary instruction before a PHI.) Fixes PR11275.
llvm-svn: 143437
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 288fe680971..0cc969b01de 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2028,9 +2028,10 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { BasicBlock *InstParent = I->getParent(); BasicBlock::iterator InsertPos = I; - if (!isa<PHINode>(Result)) // If combining a PHI, don't insert - while (isa<PHINode>(InsertPos)) // middle of a block of PHIs. - ++InsertPos; + // If we replace a PHI with something that isn't a PHI, fix up the + // insertion point. + if (!isa<PHINode>(Result) && isa<PHINode>(InsertPos)) + InsertPos = InstParent->getFirstInsertionPt(); InstParent->getInstList().insert(InsertPos, Result); |