[llvm-bugs] [Bug 49924] New: Missed load elimination

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 11 06:40:55 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49924

            Bug ID: 49924
           Summary: Missed load elimination
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

struct A
{
  int x;
} *A_ptr;

struct B
{
  struct A a;
  int y;
} *B_ptr;
int
test ()
{
  struct A ap = { 0 };
  B_ptr->y = 123;
  *A_ptr = ap;
  return B_ptr->y;
}

ICC/GCC:
test():
        mov       rax, QWORD PTR B_ptr[rip]                     #15.3
        mov       rdx, QWORD PTR A_ptr[rip]                     #16.4
        mov       DWORD PTR [4+rax], 123                        #15.3
        mov       eax, 123                                      #17.10
        mov       DWORD PTR [rdx], 0                            #16.4
        ret                                                     #17.10
A_ptr:
B_ptr:


LLVM trunk:
test():                               # @test()
        mov     rax, qword ptr [rip + B_ptr]
        mov     dword ptr [rax + 4], 123
        mov     rax, qword ptr [rip + A_ptr]
        mov     dword ptr [rax], 0
        mov     rax, qword ptr [rip + B_ptr]
        mov     eax, dword ptr [rax + 4]
        ret
A_ptr:
        .quad   0

B_ptr:
        .quad   0


https://godbolt.org/z/Pxx66j44r

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210411/6bdb5de8/attachment-0001.html>


More information about the llvm-bugs mailing list