summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-10-27 19:16:21 +0000
committerDuncan Sands <baldrick@free.fr>2011-10-27 19:16:21 +0000
commit7cb61e5a0e93948c6e2bf13f34d205beaafb8dc0 (patch)
tree549235a3d77f2fa1bbf942846babfe218480ace9 /llvm/lib/Analysis/InstructionSimplify.cpp
parent81ddd1866deceb9890c497d188fad1e875d00910 (diff)
downloadbcm5719-llvm-7cb61e5a0e93948c6e2bf13f34d205beaafb8dc0.tar.gz
bcm5719-llvm-7cb61e5a0e93948c6e2bf13f34d205beaafb8dc0.zip
Reapply commit 143028 with a fix: the problem was casting a ConstantExpr Mul
using BinaryOperator (which only works for instructions) when it should have been a cast to OverflowingBinaryOperator (which also works for constants). While there, correct a few other dubious looking uses of BinaryOperator. Thanks to Chad Rosier for the testcase. Original commit message: My super-optimizer noticed that we weren't folding this expression to true: (x *nsw x) sgt 0, where x = (y | 1). This occurs in 464.h264ref. llvm-svn: 143125
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index d9e3400f895..31cbbba5962 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -758,7 +758,8 @@ static Value *SimplifyMulInst(Value *Op0, Value *Op1, const TargetData *TD,
Value *X = 0, *Y = 0;
if ((match(Op0, m_IDiv(m_Value(X), m_Value(Y))) && Y == Op1) || // (X / Y) * Y
(match(Op1, m_IDiv(m_Value(X), m_Value(Y))) && Y == Op0)) { // Y * (X / Y)
- BinaryOperator *Div = cast<BinaryOperator>(Y == Op1 ? Op0 : Op1);
+ PossiblyExactOperator *Div =
+ cast<PossiblyExactOperator>(Y == Op1 ? Op0 : Op1);
if (Div->isExact())
return X;
}
@@ -842,7 +843,7 @@ static Value *SimplifyDiv(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1,
Value *X = 0, *Y = 0;
if (match(Op0, m_Mul(m_Value(X), m_Value(Y))) && (X == Op1 || Y == Op1)) {
if (Y != Op1) std::swap(X, Y); // Ensure expression is (X * Y) / Y, Y = Op1
- BinaryOperator *Mul = cast<BinaryOperator>(Op0);
+ OverflowingBinaryOperator *Mul = cast<OverflowingBinaryOperator>(Op0);
// If the Mul knows it does not overflow, then we are good to go.
if ((isSigned && Mul->hasNoSignedWrap()) ||
(!isSigned && Mul->hasNoUnsignedWrap()))
OpenPOWER on IntegriCloud