https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91191
Bug ID: 91191 Summary: vrp and boolean arguments Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: wilson at gcc dot gnu.org Target Milestone: --- It appears that vrp isn't propagating the ranges of incoming boolean arguments. Given this example: unsigned char reg(_Bool b) { union U { unsigned char f0; _Bool f1; }; union U u; u.f1 = b; if (u.f0 > 1) { // This cannot happen // if b is only allowed // to be 0 or 1: return 42; } return 13; } clang optimizes this to unconditionally return 13, but gcc does a compare and conditionally returns either 42 or 13 depending on the result of the compare. This happens with both x86_64 and RISC-V. Looking at the vrp dumps, I see b_3(D): VARYING