[llvm] [InstCombine] Resolve TODO: nnan nsz X / -0.0 -> copysign(inf, X) (PR #79766)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 03:08:53 PST 2024
================
@@ -1600,7 +1600,18 @@ Instruction *InstCombinerImpl::foldFDivConstantDivisor(BinaryOperator &I) {
// nnan X / +0.0 -> copysign(inf, X)
if (I.hasNoNaNs() && match(I.getOperand(1), m_Zero())) {
IRBuilder<> B(&I);
- // TODO: nnan nsz X / -0.0 -> copysign(inf, X)
+ CallInst *CopySign = B.CreateIntrinsic(
+ Intrinsic::copysign, {C->getType()},
+ {ConstantFP::getInfinity(I.getType()), I.getOperand(0)}, &I);
+ CopySign->takeName(&I);
+ return replaceInstUsesWith(I, CopySign);
+ }
+
+ // nnan nsz X / -0.0 -> copysign(inf, X)
+ if (I.hasNoNaNs() && I.hasNoSignedZeros() &&
----------------
arsenm wrote:
I'm not seeing the difference between this case and the above one, they are both inserting copysign(inf, x)?
https://github.com/llvm/llvm-project/pull/79766
More information about the llvm-commits
mailing list