llvm-project
1190b43b - [GlobalISel] Port `SimplifyDemandedBits` over (#198808)

Commit
6 days ago
[GlobalISel] Port `SimplifyDemandedBits` over (#198808) This patch port SelectionDAG-style demanded-bits simplification to `CombinerHelper::simplifyDemandedBits`, initially handling scalar `G_AND` and `G_OR`. The implementation follows the SelectionDAG version. Specifically, it recursively propagates demanded bits through operands, simplifying them and computing `KnownBits` in the same walk. It preserves the bits required by other users, handles zero-demand cases, and drops poison-generating flags or invalidates affected debug values when necessary. The minimal consumer is the opt-in `simplify_demanded_bits` rule for `G_AND` and `G_OR` in the AArch64 post-legalizer combiner. It also includes unit tests, isolated-rule and full-combiner MIR tests, and the resulting AArch64 codegen checks are included. To keep this PR small, additional consumers and selection work remain on separate branches for future PRs: - [Constant-shift handling](https://github.com/llvm/llvm-project/pull/230636) - [Truncation-of-shift integration](https://github.com/lialan/llvm-project/tree/users/lialan/gisel_trunc_shift_demanded_bits). - [Narrowing truncations of constant right shifts](https://github.com/lialan/llvm-project/tree/users/lialan/gisel_narrow_trunc_shr). - [AArch64 G_UBFX selection](https://github.com/lialan/llvm-project/tree/pr-stack/aarch64-ubfx). Tracks #150515.
Author
Parents
Loading