On Thu, 21 Mar 2019, Richard Biener wrote: > > Maybe an example would help. > > > > Consider this code: > > > > for (int i = start; i < limit; i++) { > > foo(i * 5); > > } > > > > Should GCC be entitled to turn it into > > > > int limit_tmp = i * 5; > > for (int i = start * 5; i < limit_tmp; i += 5) { > > foo(i); > > } > > > > If you answered "Yes, GCC should be allowed to do this", would you > > want a warning? And how many such warnings might there be in a typical > > program? > > I assume i is signed int. Even then GCC may not do this unless it knows > the loop is entered (start < limit).
Additionally, the compiler needs to prove that 'foo' always returns normally (i.e. cannot invoke exit/longjmp or such). Alexander