]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl-ssa: Avoid creating duplicated phis
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 24 Oct 2023 10:30:53 +0000 (11:30 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 24 Oct 2023 10:30:53 +0000 (11:30 +0100)
If make_uses_available was called twice for the same use,
we could end up trying to create duplicate definitions for
the same extended live range.

gcc/
* rtl-ssa/blocks.cc (function_info::create_degenerate_phi): Check
whether the requested phi already exists.

gcc/rtl-ssa/blocks.cc

index d46cbf1e388473c680a9dfa0d72052fcfe5f6298..ecce7a68c59bc13b502a040d89718ad060518c03 100644 (file)
@@ -525,6 +525,11 @@ function_info::create_phi (ebb_info *ebb, resource_info resource,
 phi_info *
 function_info::create_degenerate_phi (ebb_info *ebb, set_info *def)
 {
+  // Allow the function to be called twice in succession for the same def.
+  def_lookup dl = find_def (def->resource (), ebb->phi_insn ());
+  if (set_info *set = dl.matching_set ())
+    return as_a<phi_info *> (set);
+
   access_info *input = def;
   phi_info *phi = create_phi (ebb, def->resource (), &input, 1);
   if (def->is_reg ())