summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 9046c36dee8..4eaf2fd72f4 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -185,14 +185,8 @@ Value *InstCombiner::EvaluateInDifferentType(Value *V, Type *Ty,
case Instruction::Shl:
case Instruction::UDiv:
case Instruction::URem: {
- Value *LHS, *RHS;
- if (I->getOperand(0) == I->getOperand(1)) {
- // Don't create an unnecessary value if the operands are repeated.
- LHS = RHS = EvaluateInDifferentType(I->getOperand(0), Ty, isSigned);
- } else {
- LHS = EvaluateInDifferentType(I->getOperand(0), Ty, isSigned);
- RHS = EvaluateInDifferentType(I->getOperand(1), Ty, isSigned);
- }
+ Value *LHS = EvaluateInDifferentType(I->getOperand(0), Ty, isSigned);
+ Value *RHS = EvaluateInDifferentType(I->getOperand(1), Ty, isSigned);
Res = BinaryOperator::Create((Instruction::BinaryOps)Opc, LHS, RHS);
break;
}
@@ -326,15 +320,11 @@ static bool canNotEvaluateInType(Value *V, Type *Ty) {
assert(!isa<Constant>(V) && "Constant should already be handled.");
if (!isa<Instruction>(V))
return true;
- // We can't extend or shrink something that has multiple uses -- unless those
- // multiple uses are all in the same binop instruction -- doing so would
- // require duplicating the instruction which isn't profitable.
- if (!V->hasOneUse()) {
- if (!match(V->user_back(), m_BinOp()))
- return true;
- if (any_of(V->users(), [&](User *U) { return U != V->user_back(); }))
- return true;
- }
+ // We don't extend or shrink something that has multiple uses -- doing so
+ // would require duplicating the instruction which isn't profitable.
+ if (!V->hasOneUse())
+ return true;
+
return false;
}
OpenPOWER on IntegriCloud