aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-04 17:12:12 +0000
committerDan Gohman <gohman@apple.com>2009-06-04 17:12:12 +0000
commit77b81fe487de709d41dfcc97bbb2941ae1bb80af (patch)
tree9730d59d8f6ae8de964c38fd56884553c77db692 /lib/Transforms/Scalar
parent68f32cbb1f9e62d5e6047b048c0d7d217b8717e1 (diff)
downloadexternal_llvm-77b81fe487de709d41dfcc97bbb2941ae1bb80af.zip
external_llvm-77b81fe487de709d41dfcc97bbb2941ae1bb80af.tar.gz
external_llvm-77b81fe487de709d41dfcc97bbb2941ae1bb80af.tar.bz2
Don't do the X * 0.0 -> 0.0 transformation in instcombine, because
instcombine doesn't know when it's safe. To partially compensate for this, introduce new code to do this transformation in dagcombine, which can use UnsafeFPMath. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72872 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index e6f854f..8bb16f3 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2585,7 +2585,9 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
bool Changed = SimplifyCommutative(I);
Value *Op0 = I.getOperand(0);
- if (isa<UndefValue>(I.getOperand(1))) // undef * X -> 0
+ // TODO: If Op1 is undef and Op0 is finite, return zero.
+ if (!I.getType()->isFPOrFPVector() &&
+ isa<UndefValue>(I.getOperand(1))) // undef * X -> 0
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
// Simplify mul instructions with a constant RHS...
@@ -2612,16 +2614,14 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
ConstantInt::get(Op0->getType(), Val.logBase2()));
}
} else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) {
- if (Op1F->isNullValue())
- return ReplaceInstUsesWith(I, Op1);
+ // TODO: If Op1 is zero and Op0 is finite, return zero.
// "In IEEE floating point, x*1 is not equivalent to x for nans. However,
// ANSI says we can drop signals, so we can do this anyway." (from GCC)
if (Op1F->isExactlyValue(1.0))
return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul double %X, 1.0'
} else if (isa<VectorType>(Op1->getType())) {
- if (isa<ConstantAggregateZero>(Op1))
- return ReplaceInstUsesWith(I, Op1);
+ // TODO: If Op1 is all zeros and Op0 is all finite, return all zeros.
if (ConstantVector *Op1V = dyn_cast<ConstantVector>(Op1)) {
if (Op1V->isAllOnesValue()) // X * -1 == 0 - X