public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r8-10459] ldist: Further fixes for -ftrapv [PR94114]
@ 2020-09-17 14:24 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 14:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8d5332862e86edb92f27bd136ccd9fdba3524039
commit r8-10459-g8d5332862e86edb92f27bd136ccd9fdba3524039
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Mar 11 09:32:22 2020 +0100
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 <jakub@redhat.com>
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.
(cherry picked from commit 2fd27691f213f2e808626c4cd492b00c801a00fa)
Diff:
---
gcc/testsuite/gcc.dg/pr94114.c | 13 +++++++++++++
gcc/tree-loop-distribution.c | 6 +++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/pr94114.c b/gcc/testsuite/gcc.dg/pr94114.c
new file mode 100644
index 00000000000..8d6d0eb5c2a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94114.c
@@ -0,0 +1,13 @@
+/* PR tree-optimization/94114 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-distribute-patterns -ftrapv" } */
+
+void
+foo (int *x, int *y, int *z, long int w)
+{
+ while (y + w > z)
+ {
+ x[w] = 0;
+ --w;
+ }
+}
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 05766c7300d..e257c9bc433 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -1001,7 +1001,7 @@ generate_memset_builtin (struct 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);
@@ -1053,8 +1053,8 @@ generate_memcpy_builtin (struct 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 14:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 14:24 [gcc r8-10459] ldist: Further fixes for -ftrapv [PR94114] Jakub Jelinek
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).