[X86] Missed fold of `LEA + constant add` into `LEA` displacement
Open
backend:X86
backend:X86 Scheduler Models
question
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
https://godbolt.org/z/hW16s9Mxh
GCC folds `x + y + constant` into a single `lea` (`lea eax, [rdi + 1 + rsi]`) using the displacement field, while LLVM currently emits an additional arithmetic instruction for these cases (`lea eax, [rdi + rsi] \ inc eax`).
Contributor guide
Research direction
Start with the linked Godbolt example and reproduce the X86 case where LLVM emits an LEA followed by an increment. Trace the instruction-combining path responsible for LEA plus constant-add folding. Done means LLVM emits a single LEA using its displacement field for the reported pattern.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100