Skip to content

Commit 562e199

Browse files
committed
[InstCombine] Remove mul of SPF abs fold
Remove the fold working on abs in SPF representation now that we canonicalize SPF to intrinsics. This is not strictly NFC because the SPF fold might fire for non-canonical IR due to multi-use, but given the lack of test coverage, I assume this is not important.
1 parent a9d7ad2 commit 562e199

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,19 +319,12 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
319319
}
320320

321321
// abs(X) * abs(X) -> X * X
322-
// nabs(X) * nabs(X) -> X * X
323-
if (Op0 == Op1) {
324-
Value *X, *Y;
325-
SelectPatternFlavor SPF = matchSelectPattern(Op0, X, Y).Flavor;
326-
if (SPF == SPF_ABS || SPF == SPF_NABS)
327-
return BinaryOperator::CreateMul(X, X);
328-
329-
if (match(Op0, m_Intrinsic<Intrinsic::abs>(m_Value(X))))
330-
return BinaryOperator::CreateMul(X, X);
331-
}
322+
Value *X;
323+
if (Op0 == Op1 && match(Op0, m_Intrinsic<Intrinsic::abs>(m_Value(X))))
324+
return BinaryOperator::CreateMul(X, X);
332325

333326
{
334-
Value *X, *Y;
327+
Value *Y;
335328
// abs(X) * abs(Y) -> abs(X * Y)
336329
if (I.hasNoSignedWrap() &&
337330
match(Op0,
@@ -344,7 +337,7 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
344337
}
345338

346339
// -X * C --> X * -C
347-
Value *X, *Y;
340+
Value *Y;
348341
Constant *Op1C;
349342
if (match(Op0, m_Neg(m_Value(X))) && match(Op1, m_Constant(Op1C)))
350343
return BinaryOperator::CreateMul(X, ConstantExpr::getNeg(Op1C));

0 commit comments

Comments
 (0)