[llvm-bugs] [Bug 29154] New: shrink-wraping missing

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 26 10:53:17 PDT 2016


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

            Bug ID: 29154
           Summary: shrink-wraping missing
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: danielcdh at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

struct x {
  int bar();
};

struct y {
  int foo();
  struct x *m_;
  int n_;
};

int y::foo() {
  if (m_ == 0)
    return -1;
  int n;
  do { (n) = __atomic_load_n((&n_), 0); } while (0);
  if (__builtin_expect(n == -1, 0)) {
    n = m_->bar();
    __atomic_store_n((&n_), (n), 0);
  }
  return n;
}

built with -fno-omit-frame-pointer -O2

gcc version:
        cmpq    $0, (%rdi)
        je      .L3
        movl    8(%rdi), %eax
        cmpl    $-1, %eax
        je      .L9
        ret
....

llvm version:
        pushq   %rbp
        movq    %rsp, %rbp
        pushq   %rbx
        pushq   %rax
        movq    %rdi, %rbx
        movq    (%rbx), %rdi
        movl    $-1, %eax
        testq   %rdi, %rdi
        je      .LBB0_3
        movl    8(%rbx), %eax
        cmpl    $-1, %eax
        je      .LBB0_2
.LBB0_3:
        addq    $8, %rsp
        popq    %rbx
        popq    %rbp
        retq
......

GCC takes 6 instructions while llvm takes 16

-- 
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/20160826/d26eefa7/attachment.html>


More information about the llvm-bugs mailing list