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

            Bug ID: 41348
           Summary: [X86] Failure to move indvar constant offset into
                    final address gen
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: andrea.dibia...@gmail.com, craig.top...@gmail.com,
                    llvm-bugs@lists.llvm.org, llvm-...@redking.me.uk,
                    spatel+l...@rotateright.com

https://gcc.godbolt.org/z/Z2uB_v

<snip>
  leal 1(%rdx), %eax
  leaq (%rax,%rax,2), %rax
  movq %r9, (%rdi,%rax,8)
  leal 2(%rdx), %eax
  leaq (%rax,%rax,2), %rax
  movq %r11, (%rdi,%rax,8)
  leal 3(%rdx), %eax
  leaq (%rax,%rax,2), %rax
  movq %rcx, (%rdi,%rax,8)
<snip>
  leal 31(%rdx), %eax
  leaq (%rax,%rax,2), %rax
  movq %rcx, (%rdi,%rax,8)

It'd be much better to just do the "leaq (%rax,%rax,2), %rax" once without the
offset and add the constant offset into the memory op address. Even for
hardware that doesn't like complex LEA this should be a definite win.

Something like (I haven't thoroughly check the trunc/zext effects):

  leaq (%rdx,%rdx,2), %eax
  movq %r9, 3,(%rdi,%rax,8)
  movq %r11, 6,(%rdi,%rax,8)
  movq %rcx, 9(%rdi,%rax,8)
<snip>
  movq %rcx, 93(%rdi,%rax,8)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to