[PATCH] D91331: Add hook for target to customize different legalization action according to the input type

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 23:22:54 PST 2020

steven.zhang added inline comments.

Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:4335
+    // If the input is not legal, eg: i1 -> fp, then it needs to be promoted to
+    // a larger type, eg: i8 -> fp.  Even if it is legal, no libcall may exactly
craig.topper wrote:
> The input type should be legal here so I don't think this comment makes sense as is.
Ah, the evil for copy-paste. Yes, it is legal here. I will update the comments. For PowerPC, i1 is legal type, so, we need this part of code to extend it to the type that has libcall.

Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:4447
+    // We can only expand it into libcall if the TRUNC is 0.
+    const ConstantSDNode *TRUNC = dyn_cast<ConstantSDNode>(Node->getOperand(1));
+    assert(TRUNC && TRUNC->isNullValue() &&
craig.topper wrote:
> The result of a dyn_cast shouldn't be checked for null by an assert. That should just be a cast. Is it dyn_cast in the type legalizer too?
Good catch. I will update it with cast. In fact, the type legalizer didn't skip this extra operand which seems wrong.  See SoftenFloatRes_FP_ROUND(). We can fix it later I think.

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list