https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96703
Bug ID: 96703
Summary: Failure to optimize combined comparison of variables
and of variable with 0 to two comparisons with 0
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
bool f(int x, int y)
{
return x > y && y == 0;
}
This can be optimized to `return (y == 0) && (x > 0);` (This transformation
doesn't by itself make the code faster, but it probably helps with pipelined
CPUs (avoids dependency on both variables for the first comparison) and looks
like it would most likely make other optimizations easier). This transformation
is done by LLVM, but not by GCC.