https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97223
Bug ID: 97223
Summary: Failure to optimize comparison of char arithmetic to
comparison
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(char x)
{
return x < (char)(x + some_constant);
}
This (where `some-constant` is replaced by a constant expression) can be
optimized to `return x <= (CHAR_MAX - some_constant);`. This optimization is
done by LLVM, but not by GCC.