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

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

Reply via email to