Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 162d2b4

Browse files
committed
[InstCombine] remove compound fdiv pattern folds
These are fdiv-with-constant-divisor, so they already become reciprocal multiplies. The last gap for vector ops should be closed with rL325590. It's possible that we're missing folds for some edge cases with denormal intermediate constants after deleting these, but there are no tests for those patterns, and it would be better to handle denormals more consistently (and less conservatively) as noted in TODO comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325595 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c1de3c6 commit 162d2b4

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,39 +1359,13 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
13591359
if (Instruction *R = FoldOpIntoSelect(I, SI))
13601360
return R;
13611361

1362-
bool AllowReassociate = I.isFast();
13631362
if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
13641363
if (SelectInst *SI = dyn_cast<SelectInst>(Op0))
13651364
if (Instruction *R = FoldOpIntoSelect(I, SI))
13661365
return R;
1367-
1368-
if (AllowReassociate) {
1369-
Constant *C1 = nullptr;
1370-
Constant *C2 = Op1C;
1371-
Value *X;
1372-
Instruction *Res = nullptr;
1373-
1374-
if (match(Op0, m_FMul(m_Value(X), m_Constant(C1)))) {
1375-
// (X*C1)/C2 => X * (C1/C2)
1376-
Constant *C = ConstantExpr::getFDiv(C1, C2);
1377-
if (C->isNormalFP())
1378-
Res = BinaryOperator::CreateFMul(X, C);
1379-
} else if (match(Op0, m_FDiv(m_Value(X), m_Constant(C1)))) {
1380-
// (X/C1)/C2 => X /(C2*C1)
1381-
Constant *C = ConstantExpr::getFMul(C1, C2);
1382-
if (C->isNormalFP())
1383-
Res = BinaryOperator::CreateFDiv(X, C);
1384-
}
1385-
1386-
if (Res) {
1387-
Res->setFastMathFlags(I.getFastMathFlags());
1388-
return Res;
1389-
}
1390-
}
1391-
return nullptr;
13921366
}
13931367

1394-
if (AllowReassociate) {
1368+
if (I.isFast()) {
13951369
Value *X, *Y;
13961370
if (match(Op0, m_OneUse(m_FDiv(m_Value(X), m_Value(Y)))) &&
13971371
(!isa<Constant>(Y) || !isa<Constant>(Op1))) {

0 commit comments

Comments
 (0)