[llvm] [AArch64] Combine and and lsl into ubfiz (PR #118974)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 07:11:28 PST 2024
https://github.com/davemgreen commented:
> Not sure I follow, what should handle other mask sizes? In the second link you sent inst-combine does canonicalize to the same IR: https://godbolt.org/z/qqqosjP98
>
> but this musn't be happening in compilation pipeline? Also, your example is and/shl, whereas the original example is shl(zext). I noticed in SDAG there's no `ZERO_EXTEND_INREG` node as an AND with constant is used instead, are you using and/shl as that's the canonical form or something?
Yeah sorry. My point is that this adds patterns for `shl(and(x, 0xff))` and `shl(and(x, 0xffff))`, but that does not handle all the other masks that could be used, but would be valid to transform to UBFM. Maybe they don't come up in practice because of the canonicalization that the mid-end does? If DAG isn't canonicalizing `shl(and)` to `and(shl)` then I can imagine they could, maybe we should be either trying to canonicalize it in DAG (to capture this case, might cause other problems), or if it is possible to generalize the pattern or use DAG2DAG to handle the `shl(and)` patterns with any and mask. If not this seems OK.
https://github.com/llvm/llvm-project/pull/118974
More information about the llvm-commits
mailing list