https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100942
Bug ID: 100942
Summary: ccmp is not used if the value is used later
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: aarch64-linux-gnu
Take:
void foo(void);
int f1(int a, int b)
{
int c = a == 0 || b == 0;
if (c) foo();
return c;
}
------ CUT -----
Right now we produce at -O2:
stp x29, x30, [sp, -32]!
cmp w0, 0
mov x29, sp
str x19, [sp, 16]
cset w19, eq
cmp w1, 0
cset w0, eq
orr w19, w19, w0
cbnz w19, .L8
mov w0, w19
ldr x19, [sp, 16]
ldp x29, x30, [sp], 32
ret
Notice how we have cmp/cset/cmp/cset/orr.
This is a (much) reduced testcase from Xalan in SPEC 2k6.