https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114111
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-02-26
Target| |avr
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think RTL expansion only (if even) considers BRANCH_COST. I also think
that while we have if () to non-branchy code conversion we don't have the
reverse on GIMPLE so RTL expansion sees code like
_7 = c_3(D) & 64;
_1 = _7 != 0;
_2 = (int) _1;
_5 = _2 + x_4(D);
return _5;
and when setcc is available it doesn't consider test & branch. It would
only effectively do
if (_7 != 0)
_1 = 1;
else
_1 = 0;
_2 = (int) _1;
_5 = _2 + x_4(D);
return _5;
so probably not help much in practice unless we move the computation
below back into the branch during RTL optimization.
This possibly asks for a better GIMPLE representation, at least for the
purpose of getting good code for AVR. RTL expansion probably isn't the
best place to fix this.