https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100864
Bug ID: 100864
Summary: (a&!b) | b is not opimized to a | b for conditionals
Product: gcc
Version: 12.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:
_Bool f(int a, int b, _Bool e)
{
_Bool c = (a > b);
_Bool d = !c;
return (e & d) | c;
}
--- CUT ----
We get currently:
c_5 = a_3(D) > b_4(D);
_2 = a_3(D) <= b_4(D);
_1 = _2 & e_7(D);
_6 = _1 | c_5;
But this should be optimized to just:
c_5 = a_3(D) <= b_4(D);
_6 = e_7(D) | c_5;
I noticed this while fixing PR 96923.