From 05ac4d9c7b336e30413dd80c3630981151499f9e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 11 Mar 2020 09:32:22 +0100 Subject: ldist: Further fixes for -ftrapv [PR94114] As the testcase shows, arithmetics that for -ftrapv would need multiple basic blocks can show up not just in nb_bytes expressions where we are calling rewrite_to_non_trapping_overflow for a while already, but also in the pointer expression to the start of the region. While the testcase covers just the first hunk and I've failed to create a testcase for the latter, it is at least in theory possible too, so I've adjusted that hunk too. 2020-03-11 Jakub Jelinek PR tree-optimization/94114 * tree-loop-distribution.c (generate_memset_builtin): Call rewrite_to_non_trapping_overflow even on mem. (generate_memcpy_builtin): Call rewrite_to_non_trapping_overflow even on dest and src. * gcc.dg/pr94114.c: New test. --- gcc/tree-loop-distribution.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/tree-loop-distribution.c') diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index a4f0b1e..35d3821 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -1151,7 +1151,7 @@ generate_memset_builtin (class loop *loop, partition *partition) nb_bytes = rewrite_to_non_trapping_overflow (builtin->size); nb_bytes = force_gimple_operand_gsi (&gsi, nb_bytes, true, NULL_TREE, false, GSI_CONTINUE_LINKING); - mem = builtin->dst_base; + mem = rewrite_to_non_trapping_overflow (builtin->dst_base); mem = force_gimple_operand_gsi (&gsi, mem, true, NULL_TREE, false, GSI_CONTINUE_LINKING); @@ -1205,8 +1205,8 @@ generate_memcpy_builtin (class loop *loop, partition *partition) nb_bytes = rewrite_to_non_trapping_overflow (builtin->size); nb_bytes = force_gimple_operand_gsi (&gsi, nb_bytes, true, NULL_TREE, false, GSI_CONTINUE_LINKING); - dest = builtin->dst_base; - src = builtin->src_base; + dest = rewrite_to_non_trapping_overflow (builtin->dst_base); + src = rewrite_to_non_trapping_overflow (builtin->src_base); if (partition->kind == PKIND_MEMCPY || ! ptr_derefs_may_alias_p (dest, src)) kind = BUILT_IN_MEMCPY; -- cgit v1.1 From e4e9a59105a81cdd6c1328b0a5ed9fe4cc82840e Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Mon, 16 Mar 2020 11:09:14 +0800 Subject: Update post order number for merged SCC. Function loop_distribution::break_alias_scc_partitions needs to compute SCC with runtime alias edges skipped. As a result, partitions could be re-assigned larger post order number than SCC's precedent partition and distributed before the precedent one. This fixes the issue by updating the merged partition to the minimal post order in SCC. gcc/ PR tree-optimization/94125 * tree-loop-distribution.c (loop_distribution::break_alias_scc_partitions): Update post order number for merged scc. gcc/testsuite/ PR tree-optimization/94125 * gcc.dg/tree-ssa/pr94125.c: New test. --- gcc/tree-loop-distribution.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'gcc/tree-loop-distribution.c') diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 35d3821..4442321 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -2489,14 +2489,11 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg, if (cbdata.vertices_component[k] != i) continue; - /* Update postorder number so that merged reduction partition is - sorted after other partitions. */ - if (!partition_reduction_p (first) - && partition_reduction_p (partition)) - { - gcc_assert (pg->vertices[k].post < pg->vertices[j].post); - pg->vertices[j].post = pg->vertices[k].post; - } + /* Update to the minimal postordeer number of vertices in scc so + that merged partition is sorted correctly against others. */ + if (pg->vertices[j].post > pg->vertices[k].post) + pg->vertices[j].post = pg->vertices[k].post; + partition_merge_into (NULL, first, partition, FUSE_SAME_SCC); (*partitions)[k] = NULL; partition_free (partition); -- cgit v1.1 From f6e1a4cd83190746b6544917f7526fa480ca5f18 Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Wed, 13 May 2020 11:37:47 +0800 Subject: Add missing unit dependence vector in data dependence analysis Current data dependence analysis misses unit distant vector if DRs in DDR have the same invariant access functions. This adds the vector as the constant access function case. 2020-05-13 Bin Cheng PR tree-optimization/94969 gcc/ * tree-data-dependence.c (constant_access_functions): Rename to... (invariant_access_functions): ...this. Add parameter. Check for invariant access function, rather than constant. (build_classic_dist_vector): Call above function. * tree-loop-distribution.c (pg_add_dependence_edges): Add comment. gcc/testsuite/ * gcc.dg/tree-ssa/pr94969.c: New test. --- gcc/tree-loop-distribution.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/tree-loop-distribution.c') diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 4442321..b122c39 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -2080,7 +2080,8 @@ loop_distribution::pg_add_dependence_edges (struct graph *rdg, int dir, this_dir = -this_dir; /* Known dependences can still be unordered througout the - iteration space, see gcc.dg/tree-ssa/ldist-16.c. */ + iteration space, see gcc.dg/tree-ssa/ldist-16.c and + gcc.dg/tree-ssa/pr94969.c. */ if (DDR_NUM_DIST_VECTS (ddr) != 1) this_dir = 2; /* If the overlap is exact preserve stmt order. */ -- cgit v1.1