[llvm] [X86][SelectionDAG] - Add support for llvm.canonicalize intrinsic (PR #106370)

Pawan Nirpal via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 06:47:59 PDT 2024


================
@@ -1275,6 +1275,56 @@ void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
       }
     }
     break;
+    case ISD::FCANONICALIZE: {
+      const Triple &TT = DAG.getTarget().getTargetTriple();
+      if (TT.getArch() == Triple::x86 || TT.getArch() == Triple::x86_64) {
----------------
pawan-nirpal-031 wrote:

Okay, Let's try to agree on the design first. 

- If x is a constant and denormal
  - If x is a denormal flush it to zero when denormal-fp-math=preserve-sign. And generate + or – zero according to the sign. 
  - If x is the denormal mode should never be PositiveZero for x86. That should be an error, Assert when denormal-fp-math=positive.
  - If x is a denormal with mode denormal-fp-math=ieee, Perform replacement like y = x.
  - If x is a denormal with mode denormal-fp-math=dynamic, Perform y = 1.0 * x. 
- If x is a constant and a signalling NaN, replace it with a quiet NaN. 
- If x is a regular fp constant like ( 3.14, 1.7, 2.30 … etc ) 
  - Simply do a copy y = x  or in other words keep it as it is. 
- If x is an undef replace with qnan.
- If x is a variable replace with y = x * 1.0


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


More information about the llvm-commits mailing list