| Issue |
182565
|
| Summary |
[X86] Invalid relocation resolution after CMOV(LOAD(PTR0),LOAD(PTR1)) -> LOAD(CMOV(PTR0,PTR1)) folding
|
| Labels |
backend:X86,
regression
|
| Assignees |
RKSimon
|
| Reporter |
vzakhari
|
The executable reproducer with Flang was posted in https://github.com/llvm/llvm-project/pull/182084#issuecomment-3930933926
Here is an LLVM IR reproducer: [repro.ll.gz](https://github.com/user-attachments/files/25449577/repro.ll.gz)
Compilation: `llc -mtriple=x86_64 -o - -stop-after=x86-isel repro.ll`
Before https://github.com/llvm/llvm-project/pull/182084:
```
%8:gr8 = SETCCr 5, implicit $eflags
%9:gr32 = MOVZX32rr8 killed %8
%11:gr64 = IMPLICIT_DEF
%10:gr64_nosp = INSERT_SUBREG %11, killed %9, %subreg.sub_32bit
%12:gr32 = LEA64_32r %10, 1, %10, 7, $noreg
%13:gr64 = MOV64rm $rip, 1, $noreg, target-flags(x86-gotpcrel) @_QQclX4641494C, $noreg :: (load (s64) from got)
%14:gr64 = CMOV64rm %13, $rip, 1, $noreg, target-flags(x86-gotpcrel) @_QQclX50415353, $noreg, 4, implicit $eflags :: (load (s64) from got)
```
After:
```
%8:gr8 = SETCCr 5, implicit $eflags
%9:gr32 = MOVZX32rr8 killed %8
%11:gr64 = IMPLICIT_DEF
%10:gr64_nosp = INSERT_SUBREG %11, killed %9, %subreg.sub_32bit
%12:gr32 = LEA64_32r %10, 1, %10, 7, $noreg
%13:gr64 = LEA64r $rip, 1, $noreg, target-flags(x86-gotpcrel) @_QQclX50415353, $noreg
%14:gr64 = LEA64r $rip, 1, $noreg, target-flags(x86-gotpcrel) @_QQclX4641494C, $noreg
%15:gr64 = CMOV64rr %14, killed %13, 4, implicit $eflags
%16:gr64 = MOV64rm killed %15, 1, $noreg, 0, $noreg :: (load (s64))
```
It seems to be looking okay to me in the generated object file:
```
0000000000000070 <main>:
...
90: 0f 95 c0 setne %al
93: 8d 54 00 07 lea 0x7(%rax,%rax,1),%edx
97: 48 8d 05 00 00 00 00 lea 0x0(%rip),%rax # 9e <main+0x2e>
9a: R_X86_64_REX_GOTPCRELX _QQclX50415353-0x4
9e: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # a5 <main+0x35>
a1: R_X86_64_REX_GOTPCRELX _QQclX4641494C-0x4
a5: 48 0f 44 c8 cmove %rax,%rcx
a9: 48 8b 19 mov (%rcx),%rbx
```
But linker produces this in the final executable:
```
00000000004011f0 <main>:
...
401210: 0f 95 c0 setne %al
401213: 8d 54 00 07 lea 0x7(%rax,%rax,1),%edx
401217: 48 81 cc 2e 20 40 00 or $0x40202e,%rsp
40121e: 48 81 cd 32 20 40 00 or $0x402032,%rbp
401225: 48 0f 44 c8 cmove %rax,%rcx
401229: 48 8b 19 mov (%rcx),%rbx
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs