[llvm] [LegalizeDAG] Optimize CodeGen for `ISD::CTLZ_ZERO_UNDEF` (PR #83039)
Manish Kausik H via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 6 09:52:00 PDT 2024
================
@@ -5115,6 +5114,22 @@ void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
Results.push_back(DAG.getNode(ISD::TRUNCATE, dl, OVT, Tmp1));
break;
}
+ case ISD::CTLZ_ZERO_UNDEF:
+ // We know that the argument is unlikely to be zero, hence we can take a
+ // different approach as compared to ISD::CTLZ
+
+ // Any Extend the argument
+ Tmp1 = DAG.getNode(ISD::ANY_EXTEND, dl, NVT, Node->getOperand(0));
----------------
Nirhar wrote:
I agree, but I saw that Tmp1, Tmp2 etc are explicitly used for temporary nodes in other cases in this switch statement, which I guess comes from the limitation that we aren't allowed to declare new variables inside a case. Hence I decided to follow the same convention.
https://github.com/llvm/llvm-project/pull/83039
More information about the llvm-commits
mailing list