aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCasts.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 52c36ddd3f..c5ddec8b75 100644
--- a/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -165,9 +165,8 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
/// If CastOpc is a sext or zext, we are asking if the low bits of the value can
/// bit computed in a larger type, which is then and'd or sext_in_reg'd to get
/// the final result.
-bool InstCombiner::CanEvaluateInDifferentType(Value *V, const Type *Ty,
- unsigned CastOpc,
- int &NumCastsRemoved){
+static bool CanEvaluateInDifferentType(Value *V, const Type *Ty,
+ unsigned CastOpc, int &NumCastsRemoved) {
// We can always evaluate constants in another type.
if (isa<Constant>(V))
return true;
@@ -274,7 +273,9 @@ bool InstCombiner::CanEvaluateInDifferentType(Value *V, const Type *Ty,
NumCastsRemoved);
}
case Instruction::PHI: {
- // We can change a phi if we can change all operands.
+ // We can change a phi if we can change all operands. Note that we never
+ // get into trouble with cyclic PHIs here because we only consider
+ // instructions with a single use.
PHINode *PN = cast<PHINode>(I);
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
if (!CanEvaluateInDifferentType(PN->getIncomingValue(i), Ty, CastOpc,