[llvm] [X86] Fold some (truncate (srl (add X, C1), C2)) patterns to (add (truncate (srl X, C2)), C1') (PR #126448)
João Gouveia via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 13 05:08:38 PST 2025
joaotgouveia wrote:
> > [eb2f176d67cdf1955a90e71e25d6d39910d723d4e0b8a9bf8dfa229d3a6b2c1eR53685-R53686](https://github.com/llvm/llvm-project/commit/b773400981d8ca97de016f6acbe02e71b30b5779#diff-eb2f176d67cdf1955a90e71e25d6d39910d723d4e0b8a9bf8dfa229d3a6b2c1eR53685-R53686)), should I remove it entirely?
>
> This reminds me can we expand it to AND/XOR/OR/SUB, maybe in a follow up patch? Then I think we can remove it. For i64, it seems only the constant fold is benefit.
This transformation is correct for those cases as well. Expanding it to include those ops would require adding a couple of tests and expanding the `sd_match` to cover them, so it should be pretty simple. I can do it in this patch or in a follow up, depending on how wide you want the scope of this patch to be.
It looks like `AND` is already being transformed (https://godbolt.org/z/a5d5vhdsb), so for that specific operation maybe just adding a test would suffice?
https://github.com/llvm/llvm-project/pull/126448
More information about the llvm-commits
mailing list