------- Comment #1 from sebastian dot pop at cri dot ensmp dot fr 2006-11-06 11:48 ------- Subject: Re: Missed constant propagation into loops
I think the problem is that "i" is a global variable and thus foo is potentially considered as modifying "i". Have you tried void foo (void); void bar (void) { int i, j; i = 0; for (j = 0; j < 10000; j++) if (i) foo (); } This should be a simpler case that either is correctly simplified or I know what to do for making it work. For the original problem, why don't we propagate constants in # i_3 = V_MUST_DEF <i_2>; i = 0; # NONLOCAL.6_19 = PHI <NONLOCAL.6_9(5), NONLOCAL.6_11(2)>; # i_18 = PHI <i_7(5), i_3(2)>; i.e. replacing the use of i_3 with just the constant 0? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29738