[llvm-bugs] [Bug 42998] New: [x86] sub-optimal increments when optimizing for size

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 14 08:38:40 PDT 2019


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

            Bug ID: 42998
           Summary: [x86] sub-optimal increments when optimizing for size
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

Forking this off from bug 42986 - when optimizing for size, we don't recognize
inc/lea as the optimal code (the -O2 code would be better for all settings?).

https://godbolt.org/z/xhypd3

define i64 @imm1_Oz(i32 %x, i32 %y) minsize nounwind {
  %x1 = add i32 %x, 1
  %y1 = add i32 %y, 1
  %x1z = zext i32 %x1 to i64
  %y1z = zext i32 %y1 to i64
  %r = add i64 %x1z, %y1z
  ret i64 %r
}

define i64 @imm1_Os(i32 %x, i32 %y) optsize nounwind {
  %x1 = add i32 %x, 1
  %y1 = add i32 %y, 1
  %x1z = zext i32 %x1 to i64
  %y1z = zext i32 %y1 to i64
  %r = add i64 %x1z, %y1z
  ret i64 %r
}

define i64 @imm1_O2(i32 %x, i32 %y) nounwind {
  %x1 = add i32 %x, 1
  %y1 = add i32 %y, 1
  %x1z = zext i32 %x1 to i64
  %y1z = zext i32 %y1 to i64
  %r = add i64 %x1z, %y1z
  ret i64 %r
}

$ llc -o - imm1.ll

_imm1_Oz:                               ## @imm1_Oz
        pushq   $1
        popq    %rax
        leal    (%rdi,%rax), %ecx
        addl    %esi, %eax
        addq    %rcx, %rax
        retq


_imm1_Os:                               ## @imm1_Os
        movl    $1, %eax
        leal    (%rdi,%rax), %ecx
        addl    %esi, %eax
        addq    %rcx, %rax
        retq

_imm1_O2:                               ## @imm1_O2
        leal    1(%rdi), %eax
        incl    %esi
        addq    %rsi, %rax
        retq

-- 
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/20190814/5fcdb9e9/attachment.html>


More information about the llvm-bugs mailing list