[llvm-bugs] [Bug 46724] New: Failure to use x86 array arithmetic instead of manual add

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 15 04:34:54 PDT 2020


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

            Bug ID: 46724
           Summary: Failure to use x86 array arithmetic instead of manual
                    add
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

struct as
{
    as* a;
    as* b;
};

struct b
{
    as* a;
    as* b;
};

void f(b* a, as* s)
{
    if (a->a)
    {
        s->a = a->a;
        a->a->b = s;
    }
    else
    {
        a->b = s;
    }
}

With -O3, GCC outputs this :

f(b*, as*):
  mov rax, QWORD PTR [rdi]
  test rax, rax
  je .L2
  mov QWORD PTR [rsi], rax
  mov QWORD PTR [rax+8], rsi
  ret
.L2:
  mov QWORD PTR [rdi+8], rsi
  ret

LLVM outputs this :

f(b*, as*): # @f(b*, as*)
  mov rax, qword ptr [rdi]
  test rax, rax
  je .LBB0_2
  mov qword ptr [rsi], rax
  add rax, 8
  mov qword ptr [rax], rsi
  ret
.LBB0_2:
  add rdi, 8
  mov qword ptr [rdi], rsi
  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/20200715/e75f24bc/attachment.html>


More information about the llvm-bugs mailing list