forked from OSchip/llvm-project
Oops, X+0.0 isn't foldable, but X+-0.0 is.
llvm-svn: 23772
This commit is contained in:
parent
32979336a7
commit
7fde91e365
|
@ -694,11 +694,12 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
|
||||||
return ReplaceInstUsesWith(I, RHS);
|
return ReplaceInstUsesWith(I, RHS);
|
||||||
|
|
||||||
// X + 0 --> X
|
// X + 0 --> X
|
||||||
// NOTE: -0 + +0 = +0 in non-default rounding modes. When we support them
|
if (!I.getType()->isFloatingPoint()) { // NOTE: -0 + +0 = +0.
|
||||||
// we must disable this. Note that 0.0-0.0 = -0.0, so this doesn't hold
|
if (RHSC->isNullValue())
|
||||||
// for SUB.
|
return ReplaceInstUsesWith(I, LHS);
|
||||||
if (RHSC->isNullValue())
|
} else if (cast<ConstantFP>(RHSC)->isExactlyValue(-0.0)) {
|
||||||
return ReplaceInstUsesWith(I, LHS);
|
return ReplaceInstUsesWith(I, LHS);
|
||||||
|
}
|
||||||
|
|
||||||
// X + (signbit) --> X ^ signbit
|
// X + (signbit) --> X ^ signbit
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHSC)) {
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHSC)) {
|
||||||
|
|
Loading…
Reference in New Issue