https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93447
Bug ID: 93447 Summary: Value range propagation not working at -Os Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pskocik at gmail dot com Target Milestone: --- I have a lot of cases where I'd like to translate boolean conditions to negated errno codes (possibly wrapped in an struct or a trivial union). If this translation is inlinable, I'd expect that undoing it to get a boolean again (bool => negated errno => bool) would eliminate the roundtrip. GCC indeed does this at -O2 and -O3, but the optimization's failing to kick in at -Os, leading to code size increases. Clang succeeds at eliminating the roundrip at -Os (and it does this optimization already at -O1). A simple example that generates unnecessary code at -Os: #include <errno.h> _Bool addb_simple(int A, int B, int *Rp) { int ec=0; if(__builtin_add_overflow(A,B,Rp)) ec = -ERANGE; return !!ec; } https://gcc.godbolt.org/z/tGkbtD Thanks for looking into it!