[llvm] [InstCombine] Fold more 'fcmp' 'select' instrs idioms into 'fabs' (PR #83381)
Andy Kaylor via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 12:09:07 PST 2024
================
@@ -2742,7 +2742,12 @@ static Instruction *foldSelectWithFCmpToFabs(SelectInst &SI,
// Note: We require "nnan" for this fold because fcmp ignores the signbit
// of NAN, but IEEE-754 specifies the signbit of NAN values with
// fneg/fabs operations.
- if (!SI.hasNoSignedZeros() || !SI.hasNoNaNs())
+ if (!SI.hasNoNaNs())
+ return nullptr;
+
+ bool FunctionHasNoSignedZeroes =
+ SI.getParent()->getParent()->hasFnAttribute("no-signed-zeros-fp-math");
----------------
andykaylor wrote:
In principle, I agree with @arsenm about not introducing additional uses of the attribute. I said in #51601 that I couldn't see a way around it, but @nikic's suggestion about setting the flag somewhere based on the attribute might be a way around this. I can't see a reason that it wouldn't be legal for SROA to set the nsz flag when it eliminates the stores and loads in this example: https://godbolt.org/z/fahb8oM9o
https://github.com/llvm/llvm-project/pull/83381
More information about the llvm-commits
mailing list