Revert "[PR tree-optimization/90036] Backpropagate more equivalences in DOM"

This reverts commit f23a339a68.
This commit is contained in:
Jeff Law
2026-03-11 08:38:27 -06:00
parent 909d18c291
commit 0619a560b9
3 changed files with 4 additions and 105 deletions

View File

@@ -1,69 +0,0 @@
/* { dg-do compile } */
/* { dg-options "-O2 -Wall" } */
extern int sprintf (char *__restrict __s,
const char *__restrict __format, ...)
__attribute__ ((__nothrow__));
typedef int bfd_boolean;
struct stab_type_stack
{
long index;
bfd_boolean definition;
};
struct stab_write_handle
{
struct stab_type_stack *type_stack;
};
extern char *stab_pop_type (struct stab_write_handle *);
bfd_boolean stab_start_struct_type (void *, const char *, unsigned int,
bfd_boolean, unsigned int);
bfd_boolean
stab_start_class_type (void *p, const char *tag, unsigned int id,
bfd_boolean structp, unsigned int size,
bfd_boolean vptr, bfd_boolean ownvptr)
{
struct stab_write_handle *info = (struct stab_write_handle *) p;
bfd_boolean definition;
char *vstring;
if (!vptr || ownvptr)
{
definition = 0;
vstring = ((void *) 0);
}
else
{
definition = info->type_stack->definition;
vstring = stab_pop_type (info);
}
if (vptr)
{
if (ownvptr)
{
sprintf (p, "~%%%ld", info->type_stack->index);
}
else
{
sprintf (p, "~%%%s", vstring);
}
}
if (definition)
info->type_stack->definition = 1;
return 1;
}

View File

@@ -14,6 +14,7 @@
10 CONTINUE
RETURN
END
! { dg-final { scan-tree-dump-not "FIND" "dom2" } }
! We should retain both a read and write of mycommon.x.
! { dg-final { scan-tree-dump-times " _\[0-9\]+ = mycommon\\.x\\\[_\[0-9\]+\\\];" 1 "dom2" } }
! { dg-final { scan-tree-dump-times " mycommon\\.x\\\[j?_\[0-9\]+\\\] = _\[0-9\]+;" 1 "dom2" } }

View File

@@ -1097,7 +1097,6 @@ dom_valueize (tree t)
additional equivalences that are valid on edge E. */
static void
back_propagate_equivalences (tree lhs, edge e,
class avail_exprs_stack *avail_exprs_stack,
class const_and_copies *const_and_copies,
bitmap domby)
{
@@ -1150,20 +1149,6 @@ back_propagate_equivalences (tree lhs, edge e,
no_follow_ssa_edges);
if (res && (TREE_CODE (res) == SSA_NAME || is_gimple_min_invariant (res)))
record_equality (lhs2, res, const_and_copies);
/* It may also be the case that the value is in the hash table. So
try to look it up there too. But restrict ourselves to cases where
the hash lookup produced a constant rather than another SSA_NAME.
That avoids infinite recursion issues. */
res = avail_exprs_stack->lookup_avail_expr (use_stmt, false, false);
if (res && is_gimple_min_invariant (res))
{
record_equality (lhs2, res, const_and_copies);
/* And that in turn may trigger further propagation opportunities. */
back_propagate_equivalences (lhs2, e, avail_exprs_stack,
const_and_copies, domby);
}
}
}
@@ -1188,25 +1173,7 @@ record_temporary_equivalences (edge e,
/* If we have 0 = COND or 1 = COND equivalences, record them
into our expression hash tables. */
for (i = 0; edge_info->cond_equivalences.iterate (i, &eq); ++i)
{
avail_exprs_stack->record_cond (eq);
/* This is not a simple equivalence, but may still enable
discovery of other equivalences. This is fairly narrowly
implemented and can likely be generalized further.
Essentially we're looking for [0/1] = A cond [0/1] and try
to derive equivalences at use points of A. */
if ((integer_zerop (eq->value) || integer_onep (eq->value))
&& eq->cond.kind == EXPR_BINARY
&& (eq->cond.ops.binary.op == EQ_EXPR
|| eq->cond.ops.binary.op == NE_EXPR)
&& TREE_CODE (eq->cond.ops.binary.opnd0) == SSA_NAME
&& TREE_CODE (eq->cond.ops.binary.opnd1) == INTEGER_CST)
back_propagate_equivalences (eq->cond.ops.binary.opnd0, e,
avail_exprs_stack,
const_and_copies, blocks_on_stack);
}
avail_exprs_stack->record_cond (eq);
edge_info::equiv_pair *seq;
for (i = 0; edge_info->simple_equivalences.iterate (i, &seq); ++i)
@@ -1244,8 +1211,8 @@ record_temporary_equivalences (edge e,
/* Any equivalence found for LHS may result in additional
equivalences for other uses of LHS that we have already
processed. */
back_propagate_equivalences (lhs, e, avail_exprs_stack,
const_and_copies, blocks_on_stack);
back_propagate_equivalences (lhs, e, const_and_copies,
blocks_on_stack);
}
}
}