[llvm-bugs] [Bug 27202] New: [x86] optimizing for size results in bigger code because of repeated constant

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 4 13:02:58 PDT 2016


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

            Bug ID: 27202
           Summary: [x86] optimizing for size results in bigger code
                    because of repeated constant
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Noticed via bug 27105:

define i1 @foo(i32 %i) #0 {
  %and = and i32 %i, 305419896
  %cmp = icmp eq i32 %and, 305419896
  ret i1 %cmp
}

attributes #0 = { "no-frame-pointer-elim"="false" }


$ ./llc maskcmp.ll -filetype=obj ; otool -tv maskcmp.o
...
0000000000000000    andl    $0x12345678, %edi       ## imm = 0x12345678
0000000000000006    cmpl    $0x12345678, %edi       ## imm = 0x12345678
000000000000000c    sete    %al
000000000000000f    retq


Now add an 'optsize' attribute:

define i1 @foo(i32 %i) #0 {
  %and = and i32 %i, 305419896
  %cmp = icmp eq i32 %and, 305419896
  ret i1 %cmp
}

attributes #0 = { optsize "no-frame-pointer-elim"="false" }

$ ./llc maskcmp.ll -filetype=obj ; otool -tv maskcmp.o
...
0000000000000000    andl    $0x12345678, %edi       ## imm = 0x12345678
0000000000000006    movl    $0x12345678, %eax       ## imm = 0x12345678
000000000000000b    cmpl    %eax, %edi
000000000000000d    sete    %al
0000000000000010    retq


We loaded the constant into a register, but we didn't actually use it for the
'and', so the code got bigger rather than smaller.

This is probably related to bug 24448, and may be a bug introduced with:
http://reviews.llvm.org/rL244601

-- 
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/20160404/2314ddf3/attachment-0001.html>


More information about the llvm-bugs mailing list