Bug fix. Only safe to perform extension uses optimization if the source of extension...
authorEvan Cheng <evan.cheng@apple.com>
Wed, 12 Dec 2007 00:51:06 +0000 (00:51 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 12 Dec 2007 00:51:06 +0000 (00:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44896 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/CodeGenPrepare.cpp

index 594c017ba8a85d2d0a4e9a6371a1ed9fcf4d1bf8..37a645f3ce813b492bfe975e4b770f13b3582f37 100644 (file)
@@ -929,6 +929,11 @@ bool CodeGenPrepare::OptimizeExtUses(Instruction *I) {
   if (Src->hasOneUse())
     return false;
 
+  // Only safe to perform the optimization if the source is also defined in
+  // this block. 
+  if (DefBB != cast<Instruction>(Src)->getParent())
+    return false;
+
   bool DefIsLiveOut = false;
   for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); 
        UI != E; ++UI) {