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

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

Reply via email to