[llvm] [SROA] Propagate no-signed-zeros(nsz) fast-math flag on the phi node using function attribute (PR #83381)
Sushant Gokhale via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 9 21:58:25 PDT 2024
================
@@ -1113,6 +1114,17 @@ void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
for (unsigned i = 0; i != NumEdges; ++i)
APN->addIncoming(IncomingVals[AllocaNo], Pred);
+ // For the sequence `return X > 0.0 ? X : -X`, it is expected that this
+ // results in fabs intrinsic. However, without no-signed-zeros(nsz) flag
+ // on the phi node generated at this stage, fabs folding does not
+ // happen. So, we try to infer nsz flag from the function attributes to
+ // enable this fabs folding.
+ bool FnHasNSZAttr = APN->getFunction()
+ ->getFnAttribute("no-signed-zeros-fp-math")
+ .getValueAsBool();
----------------
sushgokh wrote:
you mean check this way, right?
`if(... && <check nsz flag> && ...)`
I did the above way previously
https://github.com/llvm/llvm-project/pull/83381
More information about the llvm-commits
mailing list