[llvm] [LegalizeDAG] Optimize CodeGen for `ISD::CTLZ_ZERO_UNDEF` (PR #83039)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 3 05:42:41 PDT 2024
================
@@ -655,24 +655,46 @@ SDValue DAGTypeLegalizer::PromoteIntRes_CTLZ(SDNode *N) {
}
}
- // Subtract off the extra leading bits in the bigger type.
- SDValue ExtractLeadingBits = DAG.getConstant(
- NVT.getScalarSizeInBits() - OVT.getScalarSizeInBits(), dl, NVT);
- if (!N->isVPOpcode()) {
+ unsigned CtlzOpcode = N->getOpcode();
+ if (CtlzOpcode == ISD::CTLZ || CtlzOpcode == ISD::VP_CTLZ) {
----------------
arsenm wrote:
If we properly decoupled the source and result types for these operations, like in globalisel, you would move this to the operand promote.
It's really unfortunate you need to repeat all of this logic in PromoteIntRes
https://github.com/llvm/llvm-project/pull/83039
More information about the llvm-commits
mailing list