[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
Mon Jan 29 03:35:33 PST 2024
================
@@ -1600,7 +1600,17 @@ 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);
+ } else if (I.hasNoNaNs() && I.hasNoSignedZeros() &&
----------------
arsenm wrote:
NO else after return
https://github.com/llvm/llvm-project/pull/79766
More information about the llvm-commits
mailing list