http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35545
--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> --- Following patch gets rid of OBJ_TYPE_REF Index: value-prof.c =================================================================== --- value-prof.c (revision 206040) +++ value-prof.c (working copy) @@ -1333,9 +1333,15 @@ gimple_ic (gimple icall_stmt, struct cgr cond_bb = gimple_bb (icall_stmt); gsi = gsi_for_stmt (icall_stmt); - tmp0 = make_temp_ssa_name (optype, NULL, "PROF"); - tmp1 = make_temp_ssa_name (optype, NULL, "PROF"); - tmp = unshare_expr (gimple_call_fn (icall_stmt)); + tmp0 = make_temp_ssa_name (optype, NULL, "SPEC"); + tmp1 = make_temp_ssa_name (optype, NULL, "SPEC"); + tmp = gimple_call_fn (icall_stmt); + + /* Drop OBJ_TYPE_REF expression, it is ignored by rest of + optimization queue anyway. */ + if (TREE_CODE (tmp) == OBJ_TYPE_REF) + tmp = OBJ_TYPE_REF_EXPR (tmp); + tmp = unshare_expr (tmp); load_stmt = gimple_build_assign (tmp0, tmp); gsi_insert_before (&gsi, load_stmt, GSI_SAME_STMT); but it does not help. We end up: _1 = foo; if (_1 == foo) goto <bb 8>; not much better. This nonsense appears only in optimized dump, before we have the following nonsense: # ap_9 = PHI <ap_13(6)> # prephitmp_18 = PHI <&MEM[(void *)&_ZTV1B + 16B](6)> _1 = *prephitmp_18; that is introduced by duplicating <bb 7>: # ap_2 = PHI <ap_8(5), ap_13(6)> # prephitmp_14 = PHI <&MEM[(void *)&_ZTV1A + 16B](5), &MEM[(void *)&_ZTV1B + 16B](6)> _19 = *prephitmp_14; if (_19 == foo) goto <bb 9>; else goto <bb 8>; The following patch: Index: passes.def =================================================================== --- passes.def (revision 206040) +++ passes.def (working copy) @@ -242,9 +242,9 @@ along with GCC; see the file COPYING3. only examines PHIs to discover const/copy propagation opportunities. */ NEXT_PASS (pass_phi_only_cprop); + NEXT_PASS (pass_tracer); NEXT_PASS (pass_vrp); NEXT_PASS (pass_cd_dce); - NEXT_PASS (pass_tracer); NEXT_PASS (pass_dse); NEXT_PASS (pass_forwprop); NEXT_PASS (pass_phiopt); makes us to VRP value through but only when OBJ_TYPE_REF is nout around. I think pushing tracer up is good idea - we should have at least one vrp/ccp pass after tracer. Its main purpose is to provide enough context so those forward propagating passes can do better job. it seems stupid to do it only after everything was finished. I also see why tracer would preffer DCE to be done first, but we have only so many passes to do.