[llvm-bugs] [Bug 51963] New: Simple intraprocedural DSE

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 24 15:13:20 PDT 2021


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

            Bug ID: 51963
           Summary: Simple intraprocedural DSE
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            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

__attribute__ ((noinline))
void
copy (int *a, int *b)
{
  *a=*b;
}

void foo(int b)
{
  int a = 42;
  copy (&a,&b);
}


foo:                                    # @foo
        push    rax
        mov     dword ptr [rsp + 4], edi
        mov     dword ptr [rsp], 42          <------- Useless store
        mov     rdi, rsp
        lea     rsi, [rsp + 4]
        call    copy
        pop     rax
        ret


int p,q;
__attribute__ ((noinline, noclone))

int
test (int *p)
{
  *p = 1;
}
int
test1()
{
  q = 123;
  test(&p);
  return q;
}

test1:                                  # @test1
        push    rax
        mov     dword ptr [rip + q], 123
        mov     edi, offset p
        call    test
        mov     eax, dword ptr [rip + q] // Can be mov     eax, 123
        pop     rcx
        ret

-- 
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/20210924/77a7afb3/attachment.html>


More information about the llvm-bugs mailing list