[PATCH] D151750: [DAGCombine] `select_cc seteq X, 0, 0, cttz_zero_undef(X) -> and(cttz(X), sizeof(X) - 1)`

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 10:04:22 PDT 2023


craig.topper added a comment.

In D151750#4383965 <https://reviews.llvm.org/D151750#4383965>, @mgudim wrote:

> @craig.topper
>
>> What if the target doesn't natively support CTLZ/CTTZ and only has CTLZ_ZERO_UNDEF/CTTZ_ZERO_UNDEF will end up with a select followed by the AND? What if the target doesn't support CTTZ/CTLZ at all?
>
> The extra cases that I've added will go through the same legality checks as previous cases. The checks `(!LegalOperations || TLI.isOperationLegal(ISD::CTTZ, VT)))` still apply, right?
>
> But, thanks to your comment, I've realized that I should probably add legality checks for `AND`.

`(!LegalOperations || TLI.isOperationLegal(ISD::CTTZ, VT)))` only prevents creating CTTZ in the last DAGCombine run if CTTZ isn't legal. It will still allow it to be created in the earlier runs. I don't know if we have test coverage of this pattern on a target that doesn't support cttz/ctlz.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151750/new/

https://reviews.llvm.org/D151750



More information about the llvm-commits mailing list