https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108997
Bug ID: 108997 Summary: GCC prediction on bool comparisons seems wrong Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- I noticed this while looking into 108992. I suspect we look into this but I am not 100% sure this is a bug. Testcase: void use(int *); void use2(int *); void foo(bool cond, int * p) { if (cond) { use(p); } use2(p); } GCC predicts the branch to be taken 66% of the time, but I would have assume it should be 50% as it is a bool and there is no other information. I suspect this is due to prediction when comparing against 0.