[llvm-commits] [llvm] r44905 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Evan Cheng evan.cheng at apple.com
Tue Dec 11 18:53:42 PST 2007


Author: evancheng
Date: Tue Dec 11 20:53:41 2007
New Revision: 44905

URL: http://llvm.org/viewvc/llvm-project?rev=44905&view=rev
Log:
Don't muck with phi nodes; bug fixes.

Modified:
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=44905&r1=44904&r2=44905&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Tue Dec 11 20:53:41 2007
@@ -930,8 +930,8 @@
     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 @@
   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;
 





More information about the llvm-commits mailing list