[llvm] [InstCombine] Fold more 'fcmp' 'select' instrs idioms into 'fabs' (PR #83381)
Andy Kaylor via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 15:07:31 PST 2024
================
@@ -2742,7 +2742,11 @@ 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:
It's better to look for the individual semantic modes. While `isFast()` implies `noSignedZeroes`, it is possible to enable `noSignedZeroes` without enabling other fast-math flags, so `isFast()` might return false even when `noSignedZeros` is enabled.
https://github.com/llvm/llvm-project/pull/83381
More information about the llvm-commits
mailing list