[AArch64] Replace tryShiftAmountMod with ComplexPattern-based isel
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`AArch64DAGToDAGISel::tryShiftAmountMod` handles several shift amount optimizations for SelectionDAG only. PR #223136 adds the ComplexPattern infrastructure (`SelectShiftMask`) that works for both SelectionDAG and GlobalISel.
The goal is to incrementally expand `SelectShiftMask` to cover all cases handled by `tryShiftAmountMod` and eventually remove it.
## Cases to handle
- [x] AND mask removal — #223136
- [ ] ADD/SUB by multiple of shift size (e.g. `shl x, (add y, 64)` → `shl x, y`)
- [ ] NEG generation (e.g. `shl x, (sub 64, y)` → `shl x, neg(y)`)
- [ ] NOT/MVN generation (e.g. `shl x, (sub 63, y)` → `shl x, mvn(y)`)
- [ ] ROTR support
- [ ] Remove `tryShiftAmountMod` entirely
CC @topperc @davemgreen @arsenm
Contributor guide
Research direction
Start with AArch64DAGToDAGISel::tryShiftAmountMod and the SelectShiftMask infrastructure added by PR #223136. Compare the remaining ADD/SUB, NEG, NOT/MVN, and ROTR cases with what SelectShiftMask handles in SelectionDAG and GlobalISel. Done means those cases are covered and tryShiftAmountMod can eventually be removed.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100