[llvm-bugs] [Bug 41348] New: [X86] Failure to move indvar constant offset into final address gen

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 2 08:31:33 PDT 2019


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: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: andrea.dibiagio at gmail.com, craig.topper at gmail.com,
                    llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
                    spatel+llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190402/606068b2/attachment.html>


More information about the llvm-bugs mailing list