------- Comment #7 from manu at gcc dot gnu dot org 2007-08-20 14:18 ------- Even simpler testcase:
int foo () { int i = 0; int j; if (1 == i) return j; return 0; } This will only be reliably fixed by building a better SSA representation. Moving the passes around will just solve it by chance (because CCP will assume that j undefined value is actually 0, and thus remove j). Also, it will silence many warnings (for the same reason, CCP happily initializing uninitialized variables) So instead of: foo () { int j; int i; int D.1280; <bb 0>: [pr20644.c : 3] i_2 = 0; [pr20644.c : 6] if ([pr20644.c : 6] i_2 == 1) goto <L0>; else goto <L1>; <L0>:; [pr20644.c : 7] D.1280_6 = j_5; [pr20644.c : 7] goto <bb 3> (<L2>); <L1>:; [pr20644.c : 9] D.1280_4 = 0; # D.1280_1 = PHI <D.1280_6(1), D.1280_4(2)>; <L2>:; return D.1280_1; } We could generate: foo () { int j; int i; <bb 0>: [pr20644.c : 3] i_2 = 0; [pr20644.c : 6] if ([pr20644.c : 6] i_2 == 1) goto <L0>; else goto <L1>; <L0>:; [pr20644.c : 7] goto <bb 3> (<L2>); <L1>:; [pr20644.c : 9] j_6 = 0; # j_7 = PHI <j_5(D), j_6(2)>; <L2>:; return j_7; } -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20644