https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114092
Bug ID: 114092 Summary: ADD_OVERFLOW<a, 0> with resulting type of `_Complex unsigned:1` should be reduced to just `(unsigned)(a) <= 1` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` struct d { unsigned i:1; }; _Bool f(int a, struct d b) { return __builtin_add_overflow_p(a, 0, b.i); } _Bool f1(int a, struct d b) { return a != 1 && a != 0; } ``` These 2 functions should produce the same. Here `a+0` overflows an `unsigned:1` if the value of a is not 0 or 1. We could extend this to any smaller types too if we want.