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