[llvm] [X86] Let RegAllocFast lower tied operands (PR #228968)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 20:53:43 PDT 2026


MaskRay wrote:

> With -O2 -mllvm -regalloc=fast, .text shrinks by 0.12% but the instruction count grows by 0.09%: RegAllocFast does not convert to three-address form, so where a tied source stays live, leaq 1(%rsi), %rax becomes movq %rsi, %rax; incq %rax.

Elaborate on this (-O2, not RegAllocFast was designed for): `TwoAddressInstructionImpl::convertInstTo3Addr`, which runs above -O0, can convert `INC64r` in

```
  %1:gr64_nosp = COPY $rsi
  %0:gr64 = COPY $rdi
  %2:gr64 = INC64r %1(tied-def 0), implicit-def dead $eflags
  MOV32mi %0, 4, %1, 0, $noreg, 0     ; %1 still live after the INC
  MOV32mi %0, 4, %1, 4, $noreg, 1
  $rax = COPY %2
  RET 0, $rax
```
to
```
%2:gr64 = LEA64r %1, 1, $noreg, 1, $noreg
```

RegAllocFast doesn't implement this path.

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


More information about the llvm-commits mailing list