[llvm] [InstSimply] Add tests for simplify `(fmul -x, +/-0)` -> `-/+0` (PR #85345)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 23:58:10 PDT 2024
================
@@ -5767,11 +5767,18 @@ static Value *simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF,
if (FMF.noNaNs() && FMF.noSignedZeros())
return ConstantFP::getZero(Op0->getType());
- // +normal number * (-)0.0 --> (-)0.0
KnownFPClass Known =
computeKnownFPClass(Op0, FMF, fcInf | fcNan, /*Depth=*/0, Q);
- if (Known.SignBit == false && Known.isKnownNever(fcInf | fcNan))
- return Op1;
+ if (Known.isKnownNever(fcInf | fcNan)) {
+ // +normal number * (-)0.0 --> (-)0.0
+ if (Known.SignBit == false)
+ return Op1;
+ // -normal number * (-)0.0 --> -(-)0.0
+ if (Known.SignBit == true)
+ return match(Op1, m_PosZeroFP())
+ ? ConstantFP::getNegativeZero(Op0->getType())
+ : ConstantFP::getZero(Op0->getType());
----------------
arsenm wrote:
Can also just pass the bool condition to the parameter to getZero to make it signed
https://github.com/llvm/llvm-project/pull/85345
More information about the llvm-commits
mailing list