Skip to content

Commit cfa414c

Browse files
committed
[InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF
These simplifications were previously enabled only with isFast(), but that is more restrictive than required. Since r317488, FMF has 'reassoc' to control these cases at a finer level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330089 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9325168 commit cfa414c

File tree

5 files changed

+545
-30
lines changed

5 files changed

+545
-30
lines changed

lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ Value *FAddCombine::performFactorization(Instruction *I) {
511511
}
512512

513513
Value *FAddCombine::simplify(Instruction *I) {
514-
assert(I->isFast() && "Expected 'fast' instruction");
514+
assert(I->hasAllowReassoc() && I->hasNoSignedZeros() &&
515+
"Expected 'reassoc'+'nsz' instruction");
515516

516517
// Currently we are not able to handle vector type.
517518
if (I->getType()->isVectorTy())
@@ -1378,7 +1379,7 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
13781379
if (Value *V = SimplifySelectsFeedingBinaryOp(I, LHS, RHS))
13791380
return replaceInstUsesWith(I, V);
13801381

1381-
if (I.isFast()) {
1382+
if (I.hasAllowReassoc() && I.hasNoSignedZeros()) {
13821383
if (Value *V = FAddCombine(Builder).simplify(&I))
13831384
return replaceInstUsesWith(I, V);
13841385
}
@@ -1747,7 +1748,7 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
17471748
if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1))
17481749
return replaceInstUsesWith(I, V);
17491750

1750-
if (I.isFast()) {
1751+
if (I.hasAllowReassoc() && I.hasNoSignedZeros()) {
17511752
if (Value *V = FAddCombine(Builder).simplify(&I))
17521753
return replaceInstUsesWith(I, V);
17531754
}

0 commit comments

Comments
 (0)