From: Evan Cheng Date: Wed, 12 Dec 2007 02:53:41 +0000 (+0000) Subject: Don't muck with phi nodes; bug fixes. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=765dff258545f019502023045b471443ff9ef6c4;p=oota-llvm.git Don't muck with phi nodes; bug fixes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44905 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index 37a645f3ce8..47e60cd74b4 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/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(Src)->getParent()) + // this block. + if (!isa(Src) || DefBB != cast(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(*UI); + if (User->getParent() == DefBB) continue; + if (isa(User)) + return false; + } + // InsertedTruncs - Only insert one trunc in each block once. DenseMap InsertedTruncs;