http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59660
--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 8 Jan 2014, hubicka at ucw dot cz wrote: > 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. Or simply assign to iftmp.0. Not sure why iftmp.0 is int in the first place. Probably the FEs fault. Richard.