summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-12-12 02:53:41 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-12-12 02:53:41 +0000
commit63d33cfd2b39dde297c30c85b6c5e5fe12c9abbd (patch)
tree0b306915ef4c64f91a9816b0b4f0aaa99f2c9bd6 /llvm/lib
parent4a8bc7e105256c8ae763ca4027e6eb27f0aa0d35 (diff)
downloadbcm5719-llvm-63d33cfd2b39dde297c30c85b6c5e5fe12c9abbd.tar.gz
bcm5719-llvm-63d33cfd2b39dde297c30c85b6c5e5fe12c9abbd.zip
Don't muck with phi nodes; bug fixes.
llvm-svn: 44905
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 37a645f3ce8..47e60cd74b4 100644
--- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -930,8 +930,8 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) {
return false;
// Only safe to perform the optimization if the source is also defined in
- // this block.
- if (DefBB != cast<Instruction>(Src)->getParent())
+ // this block.
+ if (!isa<Instruction>(Src) || DefBB != cast<Instruction>(Src)->getParent())
return false;
bool DefIsLiveOut = false;
@@ -948,6 +948,15 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) {
if (!DefIsLiveOut)
return false;
+ // Make sure non of the uses are PHI nodes.
+ for (Value::use_iterator UI = Src->use_begin(), E = Src->use_end();
+ UI != E; ++UI) {
+ Instruction *User = cast<Instruction>(*UI);
+ if (User->getParent() == DefBB) continue;
+ if (isa<PHINode>(User))
+ return false;
+ }
+
// InsertedTruncs - Only insert one trunc in each block once.
DenseMap<BasicBlock*, Instruction*> InsertedTruncs;
OpenPOWER on IntegriCloud