public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-4608] Revert parts of ADDR_EXPR/CONSTRUCTOR treatment change in match.pd
@ 2022-12-12 8:50 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-12-12 8:50 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:49bf49bb6174734879adcba7fb340c1c8f5dd253
commit r13-4608-g49bf49bb6174734879adcba7fb340c1c8f5dd253
Author: Richard Biener <rguenther@suse.de>
Date: Mon Dec 12 08:56:41 2022 +0100
Revert parts of ADDR_EXPR/CONSTRUCTOR treatment change in match.pd
This reverts the part that substitutes from the definition of an
SSA name to the capture, thus ADDR_EXPR@0 eventually yielding
&y_1->a[i_2] instead of _3. That's because I didn't think of
how to deal with substituting @0 in the result pattern. So
the following re-instantiates the SSA def CONSTRUCTOR handling
and in the ADDR_EXPR helpers used by match.pd handles SSA names
defined to ADDR_EXPRs transparently.
* genmatch.cc (dt_simplify::gen): Revert last change.
* match.pd: Revert simplification of CONSTUCTOR leaf handling.
(&x cmp SSA_NAME): Handle ADDR_EXPR in SSA defs.
* fold-const.cc (split_address_to_core_and_offset): Handle
ADDR_EXPRs in SSA defs.
(address_compare): Likewise.
Diff:
---
gcc/fold-const.cc | 9 +++++++++
gcc/genmatch.cc | 20 ++++----------------
gcc/match.pd | 22 +++++++++++++++-------
3 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index e80be8049e1..e4c43fbe8cb 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -16344,6 +16344,11 @@ split_address_to_core_and_offset (tree exp,
poly_int64 bitsize;
location_t loc = EXPR_LOCATION (exp);
+ if (TREE_CODE (exp) == SSA_NAME)
+ if (gassign *def = dyn_cast <gassign *> (SSA_NAME_DEF_STMT (exp)))
+ if (gimple_assign_rhs_code (def) == ADDR_EXPR)
+ exp = gimple_assign_rhs1 (def);
+
if (TREE_CODE (exp) == ADDR_EXPR)
{
core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos,
@@ -16628,6 +16633,10 @@ address_compare (tree_code code, tree type, tree op0, tree op1,
tree &base0, tree &base1, poly_int64 &off0, poly_int64 &off1,
bool generic)
{
+ if (TREE_CODE (op0) == SSA_NAME)
+ op0 = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (op0));
+ if (TREE_CODE (op1) == SSA_NAME)
+ op1 = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (op1));
gcc_checking_assert (TREE_CODE (op0) == ADDR_EXPR);
gcc_checking_assert (TREE_CODE (op1) == ADDR_EXPR);
base0 = get_addr_base_and_unit_offset (TREE_OPERAND (op0, 0), &off0);
diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index f53e61a4a8d..b56c17711e0 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -3607,26 +3607,14 @@ dt_simplify::gen (FILE *f, int indent, bool gimple, int depth ATTRIBUTE_UNUSED)
if (s->capture_max >= 0)
{
char opname[20];
- fprintf_indent (f, indent, "tree captures[%u] ATTRIBUTE_UNUSED = {",
- s->capture_max + 1);
+ fprintf_indent (f, indent, "tree captures[%u] ATTRIBUTE_UNUSED = { %s",
+ s->capture_max + 1, indexes[0]->get_name (opname));
- for (int i = 0; i <= s->capture_max; ++i)
+ for (int i = 1; i <= s->capture_max; ++i)
{
if (!indexes[i])
break;
- const char *opstr = indexes[i]->get_name (opname);
- expr *e = dyn_cast <expr *> (indexes[i]->op);
- fputs (i == 0 ? " " : ", ", f);
- if (e && gimple
- /* Transparently handle picking up CONSTRUCTOR and ADDR_EXPR
- leafs if they appear in a separate definition. */
- && (*e->operation == CONSTRUCTOR
- || *e->operation == ADDR_EXPR))
- fprintf (f, "(TREE_CODE (%s) == SSA_NAME "
- "? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (%s)) : %s)",
- opstr, opstr, opstr);
- else
- fprintf (f, "%s", opstr);
+ fprintf (f, ", %s", indexes[i]->get_name (opname));
}
fprintf (f, " };\n");
}
diff --git a/gcc/match.pd b/gcc/match.pd
index 3517605c04d..fdba5833beb 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3936,7 +3936,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(view_convert CONSTRUCTOR@0)
(with
- { tree ctor = @0; }
+ { tree ctor = (TREE_CODE (@0) == SSA_NAME
+ ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0); }
(switch
(if (CONSTRUCTOR_NELTS (ctor) == 0)
{ build_zero_cst (type); })
@@ -5735,19 +5736,23 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* SSA names are canonicalized to 2nd place. */
(cmp addr@0 SSA_NAME@1)
(with
- { poly_int64 off; tree base; }
+ {
+ poly_int64 off; tree base;
+ tree addr = (TREE_CODE (@0) == SSA_NAME
+ ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0);
+ }
/* A local variable can never be pointed to by
the default SSA name of an incoming parameter. */
(if (SSA_NAME_IS_DEFAULT_DEF (@1)
&& TREE_CODE (SSA_NAME_VAR (@1)) == PARM_DECL
- && (base = get_base_address (TREE_OPERAND (@0, 0)))
+ && (base = get_base_address (TREE_OPERAND (addr, 0)))
&& TREE_CODE (base) == VAR_DECL
&& auto_var_in_fn_p (base, current_function_decl))
(if (cmp == NE_EXPR)
{ constant_boolean_node (true, type); }
{ constant_boolean_node (false, type); })
/* If the address is based on @1 decide using the offset. */
- (if ((base = get_addr_base_and_unit_offset (TREE_OPERAND (@0, 0), &off))
+ (if ((base = get_addr_base_and_unit_offset (TREE_OPERAND (addr, 0), &off))
&& TREE_CODE (base) == MEM_REF
&& TREE_OPERAND (base, 0) == @1)
(with { off += mem_ref_offset (base).force_shwi (); }
@@ -7302,7 +7307,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
== tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0))))))))
(with
{
- tree ctor = @0;
+ tree ctor = (TREE_CODE (@0) == SSA_NAME
+ ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0);
tree eltype = TREE_TYPE (TREE_TYPE (ctor));
unsigned HOST_WIDE_INT width = tree_to_uhwi (TYPE_SIZE (eltype));
unsigned HOST_WIDE_INT n = tree_to_uhwi (@1);
@@ -7950,7 +7956,8 @@ and,
/* Fold reduction of a single nonzero element constructor. */
(for reduc (IFN_REDUC_PLUS IFN_REDUC_IOR IFN_REDUC_XOR)
(simplify (reduc (CONSTRUCTOR@0))
- (with { tree ctor = @0;
+ (with { tree ctor = (TREE_CODE (@0) == SSA_NAME
+ ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0);
tree elt = ctor_single_nonzero_element (ctor); }
(if (elt
&& !HONOR_SNANS (type)
@@ -8169,7 +8176,8 @@ and,
(match vec_same_elem_p
CONSTRUCTOR@0
- (if (uniform_vector_p (@0))))
+ (if (TREE_CODE (@0) == SSA_NAME
+ && uniform_vector_p (gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0))))))
(match vec_same_elem_p
@0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-12 8:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 8:50 [gcc r13-4608] Revert parts of ADDR_EXPR/CONSTRUCTOR treatment change in match.pd Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).