https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106724
Bug ID: 106724
Summary: logical-op-non-short-circuit maybe should be 1
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Target: riscv
Take:
int f(int a, int b, int c, int d)
{
return a > b && c > d;
}
---- CUT ---
Currently on riscv32 at -O2 produces:
f:
ble a0,a1,.L3
sgt a0,a2,a3
ret
.L3:
li a0,0
ret
But add --param logical-op-non-short-circuit=1, produces:
f:
sgt a0,a0,a1
sgt a2,a2,a3
and a0,a0,a2
ret
Which is much better, especially on in-order cores.