]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Do not add partial equivalences with no uses.
authorAndrew MacLeod <amacleod@redhat.com>
Thu, 12 Oct 2023 21:06:36 +0000 (17:06 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Fri, 13 Oct 2023 13:13:10 +0000 (09:13 -0400)
PR tree-optimization/111622
* value-relation.cc (equiv_oracle::add_partial_equiv): Do not
register a partial equivalence if an operand has no uses.

gcc/value-relation.cc

index 0326fe7cde6236255507263455794e846f78ee21..c0f513a0eb17f14a3c19e8002f2144a3255e3539 100644 (file)
@@ -392,6 +392,9 @@ equiv_oracle::add_partial_equiv (relation_kind r, tree op1, tree op2)
       // In either case, if PE2 has an entry, we simply do nothing.
       if (pe2.members)
        return;
+      // If there are no uses of op2, do not register.
+      if (has_zero_uses (op2))
+       return;
       // PE1 is the LHS and already has members, so everything in the set
       // should be a slice of PE2 rather than PE1.
       pe2.code = pe_min (r, pe1.code);
@@ -409,6 +412,9 @@ equiv_oracle::add_partial_equiv (relation_kind r, tree op1, tree op2)
     }
   if (pe2.members)
     {
+      // If there are no uses of op1, do not register.
+      if (has_zero_uses (op1))
+       return;
       pe1.ssa_base = pe2.ssa_base;
       // If pe2 is a 16 bit value, but only an 8 bit copy, we can't be any
       // more than an 8 bit equivalence here, so choose MIN value.
@@ -418,6 +424,9 @@ equiv_oracle::add_partial_equiv (relation_kind r, tree op1, tree op2)
     }
   else
     {
+      // If there are no uses of either operand, do not register.
+      if (has_zero_uses (op1) || has_zero_uses (op2))
+       return;
       // Neither name has an entry, simply create op1 as slice of op2.
       pe2.code = bits_to_pe (TYPE_PRECISION (TREE_TYPE (op2)));
       if (pe2.code == VREL_VARYING)