Open ZY546 opened 1 year ago
@llvm/issue-subscribers-backend-x86
Author: None (ZY546)
The x86-fixup-LEAs pass is splitting the 3-op LEAs but we don't merge the now matching 2-op LEAs:
# Machine code for function test(int, int): NoPHIs, TracksLiveness, NoVRegs, TiedOpsRewritten, TracksDebugUserValues
Function Live Ins: $edi, $esi
bb.0.entry:
liveins: $edi, $esi
renamable $esi = KILL $esi, implicit-def $rsi
renamable $edi = KILL $edi, implicit-def $rdi
renamable $eax = nsw LEA64_32r renamable $rsi, 1, renamable $rdi, 1, $noreg
renamable $rcx = MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @x, $noreg :: (load (s64) from got)
MOV32mr killed renamable $rcx, 1, $noreg, 0, $noreg, killed renamable $eax :: (store (s32) into @x)
renamable $eax = nsw LEA64_32r killed renamable $rsi, 1, killed renamable $rdi, 2, $noreg
renamable $rcx = MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @y, $noreg :: (load (s64) from got)
MOV32mr killed renamable $rcx, 1, $noreg, 0, $noreg, killed renamable $eax :: (store (s32) into @y)
RET64
# End machine code for function test(int, int).
-->
# Machine code for function test(int, int): NoPHIs, TracksLiveness, NoVRegs, TiedOpsRewritten, TracksDebugUserValues
Function Live Ins: $edi, $esi
bb.0.entry:
liveins: $edi, $esi
renamable $esi = KILL $esi, implicit-def $rsi
renamable $edi = KILL $edi, implicit-def $rdi
renamable $eax = LEA64_32r renamable $rsi, 1, renamable $rdi, 0, $noreg
$eax = INC32r $eax(tied-def 0), implicit-def $eflags
renamable $rcx = MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @x, $noreg :: (load (s64) from got)
MOV32mr killed renamable $rcx, 1, $noreg, 0, $noreg, killed renamable $eax :: (store (s32) into @x)
renamable $eax = LEA64_32r killed renamable $rsi, 1, killed renamable $rdi, 0, $noreg
$eax = ADD32ri $eax(tied-def 0), 2, implicit-def $eflags
renamable $rcx = MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @y, $noreg :: (load (s64) from got)
MOV32mr killed renamable $rcx, 1, $noreg, 0, $noreg, killed renamable $eax :: (store (s32) into @y)
RET64
# End machine code for function test(int, int).
For the following test cases,
cse
has been done in llvm ir, but on x86, the final assembler code seems to break this optimization: https://godbolt.org/z/EYc9c66jKMaybe
lea eax, [rsi + rdi]
should not be repeated twice.