[Bug ipa/84658] [7/8 Regression] -O3 -fmerge-all-constants causes incorrect for-each loop generation.

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 2 12:44:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84658

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Tried to look at the ccp2-uid-details dump and can't make any sense from that,
so I think we need Richi on this.

A guess would be that something somewhere looks through the alais at one point
and not the other point, it is referenced just in
  # __for_begin_5 = PHI <&aD.2373(5), __for_begin_7(7)>
  if (__for_begin_5 == &MEM[(voidD.46 *)&aD.2373 + 64B])
and similarly
  # __for_begin_8 = PHI <&aD.2363(2), __for_begin_10(4)>
  if (__for_begin_8 == &MEM[(voidD.46 *)&aD.2363 + 64B])
for the variable we've kept as variable, not alias, or something is upset by
the const variable without initializer.

The alias has been created and its DECL_INITIAL cleared by sem_variable::merge,
2265          DECL_INITIAL (alias->decl) = NULL;
2266          ((symtab_node *)alias)->call_for_symbol_and_aliases
(clear_decl_rtl,
2267                                                               NULL, true);
2268          alias->need_bounds_init = false;
2269          alias->remove_all_references ();
2270          if (TREE_ADDRESSABLE (alias->decl))
2271            original->call_for_symbol_and_aliases (set_addressable, NULL,
true);
2272    
2273          varpool_node::create_alias (alias_var->decl, decl);
2274          alias->resolve_alias (original);
2275    
2276          if (dump_file)
2277            fprintf (dump_file, "Unified; Variable alias has been
created.\n");
Not really sure if it isn't an optimization problem if optimizers don't see the
initializer (if they are smart enough to look through the alias).


More information about the Gcc-bugs mailing list