[llvm-bugs] [Bug 43823] New: Missed opportunity to use cmp with exx instead od rxx (code size optimization)
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Oct 27 07:45:09 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43823
Bug ID: 43823
Summary: Missed opportunity to use cmp with exx instead od rxx
(code size optimization)
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
bool test1(U64 val)
{
return ((U32)(val & 0x120)) == 0x20;
}
define dso_local zeroext i1 @test1(i64 %0) local_unnamed_addr #0 {
%2 = and i64 %0, 288
%3 = icmp eq i64 %2, 32
ret i1 %3
}
test1:
and edi, 288
cmp rdi, 32
sete al
ret
(-O0's trunc LLVM IR instruction is eliminated)
but codegen could use "cmp edi" instead of "cmp rdi":
test1:
and edi, 288
cmp edi, 32
sete al
ret
GCC does this code size optimization (eliminate REX prefix), Clang does not.
Another opportunity for "cmp edi":
bool test2(U64 val)
{
return (val & 0x120) == 0x20;
}
test2:
and edi, 288
cmp rdi, 32
sete al
ret
Both GCC and Clang fails to use rdi for "test2" case.
https://godbolt.org/z/A0hjTg
Another case:
bool test3(U64 val)
{
return ((short)(val & 0x120)) == 0x20;
}
Clang
test3: # @test3
and edi, 288
cmp rdi, 32
sete al
ret
GCC
test3:
and di, 288
cmp di, 32
sete al
ret
--
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/20191027/8305529d/attachment.html>
More information about the llvm-bugs
mailing list