[llvm] [InstCombine] Fold more 'fcmp' 'select' instrs idioms into 'fabs' (PR #83381)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 02:43:57 PDT 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");
----------------
sushgokh wrote:

I tried 
```
bool FnHasNszAttr = SI.getFunction()->getFnAttribute("no-signed-zeros-fp-math").getValueAsBool();
```
But this is returning false while below code is returning true
```
bool FnHasNszAttr = SI.getFunction()->hasFnAttribute("no-signed-zeros-fp-math")
```
Is there anything I am misinterpreting?

https://github.com/llvm/llvm-project/pull/83381


More information about the llvm-commits mailing list