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: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to