[Bug tree-optimization/108997] New: GCC prediction on bool comparisons seems wrong
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 2 22:51:37 GMT 2023
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.
More information about the Gcc-bugs
mailing list