[llvm] [DAGCombine] Transform `shl X, cttz(Y)` to `mul (Y & -Y), X` if cttz is unsupported (PR #85066)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 07:32:24 PDT 2024
================
@@ -9962,6 +9962,18 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
if (SDValue NewSHL = visitShiftByConstant(N))
return NewSHL;
+ // fold (shl X, cttz(Y)) -> (mul (Y & -Y), X) if cttz is unsupported on the
+ // target.
+ if ((N1.getOpcode() == ISD::CTTZ || N1.getOpcode() == ISD::CTTZ_ZERO_UNDEF) &&
+ N1.hasOneUse() && !TLI.isOperationLegalOrCustom(ISD::CTTZ, VT) &&
----------------
dtcxzyw wrote:
> Right condition might be isLegalOrCustom(CTTZ||CTTZ_ZERO_UNDEF)
Unfortunately it doesn't work :(
https://github.com/llvm/llvm-project/pull/85066
More information about the llvm-commits
mailing list