http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491
--- Comment #8 from amker.cheng <amker.cheng at gmail dot com> 2012-02-17 03:55:24 UTC --- (In reply to comment #7) > With tree hoisting we generate > > <bb 2>: > pretmp.5_19 = data_0; > pretmp.5_20 = data_3; > i_21 = pretmp.5_19 + pretmp.5_20; > if (data_3(D) != 0) > goto <bb 3>; > else > goto <bb 4>; > > <bb 3>: > > <bb 4>: > # v_1 = PHI <v_7(D)(3), 2(2)> > # i_2 = PHI <i_21(3), 5(2)> > D.1719_14 = v_1 * i_21; > D.1718_15 = i_2 * D.1719_14; > return D.1718_15; > > instead of > > <bb 2>: > if (data_3(D) != 0) > goto <bb 4>; > else > goto <bb 3>; > > <bb 3>: > pretmp.5_19 = data_0; > pretmp.5_21 = data_3; > i_23 = pretmp.5_19 + pretmp.5_21; > goto <bb 5>; > > <bb 4>: > data_0.0_4 = data_0; > data_3.1_5 = data_3; > i_6 = data_0.0_4 + data_3.1_5; > > <bb 5>: > # v_1 = PHI <v_7(D)(4), 2(3)> > # i_2 = PHI <i_6(4), 5(3)> > # i_24 = PHI <i_6(4), i_23(3)> > D.1719_14 = v_1 * i_24; > D.1718_15 = i_2 * D.1719_14; > return D.1718_15; > > } > > I suppose that's good enough? See that PRE still inserts loads from > register variables, not sure if you'd want to disallow that as well. I think the reason why gcc inserts loads from global register variable is gcc treats loads/uses of such variable as memory references. If I am right, It seems a ssa issue, rather than PRE. As for the original bug, it is caused by loading const global register variable, then using the loaded ssa var across function calls(this step by pre), which introduces unnecessary register conflict. I guess the load itself won't hurt, but not sure whether hoisting will(as pre had done before). BTW, I did not get the hoisted code on trunk. Is it a patch your are working on? Thanks.