[llvm] SelectionDAG: Support nofpclass(nan/qnan/snan) in arguments (PR #130051)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 6 21:52:21 PST 2025


================
@@ -11885,6 +11885,16 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
           AssertOp = ISD::AssertSext;
         else if (Arg.hasAttribute(Attribute::ZExt))
           AssertOp = ISD::AssertZext;
+        if (Arg.hasAttribute(Attribute::NoFPClass)) {
+          SDNodeFlags InValFlags = InVals[i]->getFlags();
+          bool NoSNaN = ((Arg.getNoFPClass() & llvm::fcSNan) == llvm::fcSNan);
+          bool NoQNaN = ((Arg.getNoFPClass() & llvm::fcQNan) == llvm::fcQNan);
+          InValFlags.setNoSNaNs(NoSNaN);
+          InValFlags.setNoQNaNs(NoQNaN);
+          InValFlags.setNoInfs((Arg.getNoFPClass() & llvm::fcInf) ==
+                               llvm::fcInf);
+          InVals[i]->setFlags(InValFlags);
----------------
arsenm wrote:

> The flag here is not FastMathFlags, and it is not used to an operators.

You are setting the SDNodeFlags equivalent of FastMathFlags on an unknown operation

> It is nofpclass for variables.

My objection is what you are outputting here, I understand the original thing used nofpclass. You are transmuting it into a flag on an arbitrary SDNode

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


More information about the llvm-commits mailing list