https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94798
Bug ID: 94798
Summary: Failure to optimize subtraction and 0 literal properly
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
int f(int a, int b)
{
return (b >= a) ? (b - a) : 0;
}
Generates some *really* bad code with GCC right now, it seems to forget such
basic things as how to set a register to 0 on x86. LLVM generates good code.
Comparison here : https://godbolt.org/z/LZ8dBy
Also, this seems to have regressed back in GCC 4.9, GCC 4.8 at least generates
a `xor reg, reg` instead of a `mov reg, 0`