[llvm] [InstCombine] Split div/rem by a select of constants with a variable dividend (PR #216908)

Adam Scott via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 21:21:35 PDT 2026


as4230 wrote:

> Should the DAG part be a separate PR?

Yes definitely. That was me getting something working end to end first.

Both InstCombine and DAGCombine want to merge the two divisions back into one (foldSelectOpOp and foldSelectOfBinops) so the fold undoes itself without something stopping them.

I think the plan is three PRs. This one for the select shape which is what the GCC tests in the issue use. Then the DAG side to stop the non pow2 case being merged back at ISel. Then the loop of scalars shape from your comment https://github.com/llvm/llvm-project/issues/214466#issuecomment-5251561744, where the bool is a load so it arrives as `zext(or disjoint(%b, 4))` instead of a select.


https://github.com/llvm/llvm-project/pull/216908


More information about the llvm-commits mailing list