https://bugs.llvm.org/show_bug.cgi?id=42189
Bug ID: 42189
Summary: Avoid copy to reg before cmp
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
int g();
int f();
int shortmax(short c)
{
if (c == 32767)
return g();
return f();
}
Clang:
shortmax(short):
movzx eax, di
cmp eax, 32767
jne .LBB0_2
jmp g()
.LBB0_2:
jmp f()
But shouldn't we just use cmp di, 32767?
And I am just looking what -Os produces, and this is really interesting...
shortmax(short):
movzx eax, di
cmp eax, 32767
jne f() // neat
jmp g()
So for this pattern
if (x) call fn1();
else call fn2();
Possibly -O2/O3 should do this tranformation too?
Maybe ideal code (what -O3 should produce) for my example is:
shortmax(short):
cmp di, 32767
jne f()
jmp g()
?
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs