From 464a3d2fe53362281eba123c3099346f625edd58 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 29 Aug 2024 18:48:16 -0400 Subject: Use std::unique_ptr for optinfo_item As preliminary work towards an overhaul of how optinfo_items interact with dump_pretty_printer, replace uses of optinfo_item * with std::unique_ptr to make ownership clearer. No functional change intended. gcc/ChangeLog: * config/aarch64/aarch64.cc: Define INCLUDE_MEMORY. * config/arm/arm.cc: Likewise. * config/i386/i386.cc: Likewise. * config/loongarch/loongarch.cc: Likewise. * config/riscv/riscv-vector-costs.cc: Likewise. * config/riscv/riscv.cc: Likewise. * config/rs6000/rs6000.cc: Likewise. * dump-context.h (dump_context::emit_item): Convert "item" param from * to const &. (dump_pretty_printer::stash_item): Convert "item" param from optinfo_ * to std::unique_ptr. (dump_pretty_printer::emit_item): Likewise. * dumpfile.cc: Include "make-unique.h". (make_item_for_dump_gimple_stmt): Replace uses of optinfo_item * with std::unique_ptr. (dump_context::dump_gimple_stmt): Likewise. (make_item_for_dump_gimple_expr): Likewise. (dump_context::dump_gimple_expr): Likewise. (make_item_for_dump_generic_expr): Likewise. (dump_context::dump_generic_expr): Likewise. (make_item_for_dump_symtab_node): Likewise. (dump_pretty_printer::emit_items): Likewise. (dump_pretty_printer::emit_any_pending_textual_chunks): Likewise. (dump_pretty_printer::emit_item): Likewise. (dump_pretty_printer::stash_item): Likewise. (dump_pretty_printer::decode_format): Likewise. (dump_context::dump_printf_va): Fix overlong line. (make_item_for_dump_dec): Replace uses of optinfo_item * with std::unique_ptr. (dump_context::dump_dec): Likewise. (dump_context::dump_symtab_node): Likewise. (dump_context::begin_scope): Likewise. (dump_context::emit_item): Likewise. * gimple-loop-interchange.cc: Define INCLUDE_MEMORY. * gimple-loop-jam.cc: Likewise. * gimple-loop-versioning.cc: Likewise. * graphite-dependences.cc: Likewise. * graphite-isl-ast-to-gimple.cc: Likewise. * graphite-optimize-isl.cc: Likewise. * graphite-poly.cc: Likewise. * graphite-scop-detection.cc: Likewise. * graphite-sese-to-poly.cc: Likewise. * graphite.cc: Likewise. * opt-problem.cc: Likewise. * optinfo.cc (optinfo::add_item): Convert "item" param from optinfo_ * to std::unique_ptr. (optinfo::emit_for_opt_problem): Update for change to dump_context::emit_item. * optinfo.h: Add #error to fail immediately if INCLUDE_MEMORY wasn't defined, rather than fail to find std::unique_ptr. (optinfo::add_item): Convert "item" param from optinfo_ * to std::unique_ptr. * sese.cc: Define INCLUDE_MEMORY. * targhooks.cc: Likewise. * tree-data-ref.cc: Likewise. * tree-if-conv.cc: Likewise. * tree-loop-distribution.cc: Likewise. * tree-parloops.cc: Likewise. * tree-predcom.cc: Likewise. * tree-ssa-live.cc: Likewise. * tree-ssa-loop-ivcanon.cc: Likewise. * tree-ssa-loop-ivopts.cc: Likewise. * tree-ssa-loop-prefetch.cc: Likewise. * tree-ssa-loop-unswitch.cc: Likewise. * tree-ssa-phiopt.cc: Likewise. * tree-ssa-threadbackward.cc: Likewise. * tree-ssa-threadupdate.cc: Likewise. * tree-vect-data-refs.cc: Likewise. * tree-vect-generic.cc: Likewise. * tree-vect-loop-manip.cc: Likewise. * tree-vect-loop.cc: Likewise. * tree-vect-patterns.cc: Likewise. * tree-vect-slp-patterns.cc: Likewise. * tree-vect-slp.cc: Likewise. * tree-vect-stmts.cc: Likewise. * tree-vectorizer.cc: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/dump_plugin.c: Define INCLUDE_MEMORY. Signed-off-by: David Malcolm --- gcc/tree-data-ref.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/tree-data-ref.cc') diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index bd61069..48798f4 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -74,6 +74,7 @@ along with GCC; see the file COPYING3. If not see */ #define INCLUDE_ALGORITHM +#define INCLUDE_MEMORY #include "config.h" #include "system.h" #include "coretypes.h" -- cgit v1.1 From 1d0cb3b5fca69b81e69cfdb4aea0eebc1ac04750 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 18 Sep 2024 09:52:55 +0200 Subject: tree-optimization/116585 - SSA corruption with split_constant_offset split_constant_offset when looking through SSA defs can end up picking SSA leafs that are subject to abnormal coalescing. This can lead to downstream consumers to insert code based on the result (like from dataref analysis) in places that violate constraints for abnormal coalescing. It's best to not expand defs whose operands are subject to abnormal coalescing - and not either do something when a subexpression has operands like that already. PR tree-optimization/116585 * tree-data-ref.cc (split_constant_offset_1): When either operand is subject to abnormal coalescing do no further processing. * gcc.dg/torture/pr116585.c: New testcase. --- gcc/tree-data-ref.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/tree-data-ref.cc') diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index 48798f4..26e6d9a 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -766,6 +766,14 @@ split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1, if (INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type)) return false; + if (TREE_CODE (op0) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op0)) + return false; + if (op1 + && TREE_CODE (op1) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op1)) + return false; + switch (code) { case INTEGER_CST: @@ -861,9 +869,6 @@ split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1, case SSA_NAME: { - if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op0)) - return false; - gimple *def_stmt = SSA_NAME_DEF_STMT (op0); enum tree_code subcode; -- cgit v1.1 From 605d05b9481832bc691685b7ff990ef68f02b1bb Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 19 Sep 2024 12:37:13 +0200 Subject: Always dump generated distance vectors There's special-casing for equal access functions which bypasses printing the distance vectors. The following makes sure we print them always which helps debugging. * tree-data-ref.cc (build_classic_dist_vector): Move distance vector dumping to single caller ... (subscript_dependence_tester): ... here, dumping always when we succeed computing it. --- gcc/tree-data-ref.cc | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'gcc/tree-data-ref.cc') diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index 26e6d9a..0f173e8 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -5547,21 +5547,6 @@ build_classic_dist_vector (struct data_dependence_relation *ddr, DDR_NB_LOOPS (ddr), 0)); } - if (dump_file && (dump_flags & TDF_DETAILS)) - { - unsigned i; - - fprintf (dump_file, "(build_classic_dist_vector\n"); - for (i = 0; i < DDR_NUM_DIST_VECTS (ddr); i++) - { - fprintf (dump_file, " dist_vector = ("); - print_lambda_vector (dump_file, DDR_DIST_VECT (ddr, i), - DDR_NB_LOOPS (ddr)); - fprintf (dump_file, " )\n"); - } - fprintf (dump_file, ")\n"); - } - return true; } @@ -5673,7 +5658,24 @@ subscript_dependence_tester (struct data_dependence_relation *ddr, compute_subscript_distance (ddr); if (build_classic_dist_vector (ddr, loop_nest)) - build_classic_dir_vector (ddr); + { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + unsigned i; + + fprintf (dump_file, "(build_classic_dist_vector\n"); + for (i = 0; i < DDR_NUM_DIST_VECTS (ddr); i++) + { + fprintf (dump_file, " dist_vector = ("); + print_lambda_vector (dump_file, DDR_DIST_VECT (ddr, i), + DDR_NB_LOOPS (ddr)); + fprintf (dump_file, " )\n"); + } + fprintf (dump_file, ")\n"); + } + + build_classic_dir_vector (ddr); + } } /* Returns true when all the access functions of A are affine or -- cgit v1.1 From 5b5a36b122e1205449f1512bf39521b669e713ef Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 19 Sep 2024 14:58:18 +0200 Subject: tree-optimization/116768 - wrong dependence analysis The following reverts a bogus fix done for PR101009 and instead makes sure we get into the same_access_functions () case when computing the distance vector for g[1] and g[1] where the constants ended up having different types. The generic code doesn't seem to handle loop invariant dependences. The special case gets us both ( 0 ) and ( 1 ) as distance vectors while formerly we got ( 1 ), which the PR101009 fix changed to ( 0 ) with bad effects on other cases as shown in this PR. PR tree-optimization/116768 * tree-data-ref.cc (build_classic_dist_vector_1): Revert PR101009 change. * tree-chrec.cc (eq_evolutions_p): Make sure (sizetype)1 and (int)1 compare equal. * gcc.dg/torture/pr116768.c: New testcase. --- gcc/tree-data-ref.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'gcc/tree-data-ref.cc') diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index 0f173e8..de234c6 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -5223,8 +5223,6 @@ build_classic_dist_vector_1 (struct data_dependence_relation *ddr, non_affine_dependence_relation (ddr); return false; } - else - *init_b = true; } return true; -- cgit v1.1