[Bug tree-optimization/59660] We fail to optimize common boolean checks pre-inlining
hubicka at ucw dot cz
gcc-bugzilla@gcc.gnu.org
Wed Jan 8 13:09:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59660
--- Comment #6 from Jan Hubicka <hubicka at ucw dot cz> ---
> That's only optimizable after the 'mergephi' pass. Before the
> temporary setting is shared by the n==m code. Thus maybe
> 'mergephi' itself can handle this ...
Yep, mergephi seems like resonable place (at least it shares a lot of
letters in the pass name as phiopt).
I still think gimplifier itself could produce instead of:
m_is_less_than_n (int n, int m)
{
_Bool D.2089;
int D.2088;
int iftmp.0;
_Bool D.2082;
if (n == m) goto <D.2084>; else goto <D.2087>;
<D.2087>:
D.2088 = n + -1;
D.2089 = m_is_less_than_n (D.2088, m);
if (D.2089 != 0) goto <D.2084>; else goto <D.2085>;
<D.2084>:
iftmp.0 = 1;
goto <D.2086>;
<D.2085>:
iftmp.0 = 0;
<D.2086>:
D.2082 = (_Bool) iftmp.0;
goto <D.2090>;
<D.2090>:
return D.2082;
}
simplified version
m_is_less_than_n (int n, int m)
{
_Bool D.2089;
int D.2088;
int iftmp.0;
_Bool D.2082;
if (n == m) goto <D.2084>; else goto <D.2087>;
<D.2084>
D.2082 = 0;
goto D.2090
<D.2087>:
D.2088 = n + -1;
D.2082 = m_is_less_than_n (D.2088, m);
goto <D.2090>;
<D.2090>:
return D.2082;
}
Since this is pretty common pattern it should show as compile time improvement
even at -O0.
Honza
More information about the Gcc-bugs
mailing list