aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 594c017ba8..37a645f3ce 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -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) {