[llvm] SelectionDAG: Support nofpclass (PR #108350)

YunQiang Su via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 20:37:13 PDT 2024


================
@@ -11773,6 +11773,14 @@ 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();
+          InValFlags.setNonNeg(Arg.getNoFPClass() & llvm::fcNegative);
+          InValFlags.setNoNaNs(Arg.getNoFPClass() & llvm::fcNan);
+          InValFlags.setNoInfs(Arg.getNoFPClass() & llvm::fcInf);
+          InValFlags.setNoSignedZeros(Arg.getNoFPClass() & llvm::fcNegZero);
----------------
wzssyqa wrote:

> You can't infer no signed zeros from the fp classes.
> 
I searched the whole code, almost (if not all) of references of it are in methods to work with float.

> I believe the non-neg flag specifically is for integer contexts, and I don't think should be repurposed for FP values this way.
> 

Oh. yes. You are right, it is used to work with interger, such as IMM values etc.

> The no-nans/no-infs case is plausible, but this handling is incorrect. You need to ensure that both bits are set (e.gi getNoFPClass & fcInf == fcInf)

OK, thanks.


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


More information about the llvm-commits mailing list