public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-11352] cse: Fix up CSE const_anchor handling [PR108193]
@ 2023-05-03 15:20 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2023-05-03 15:20 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:14cb8af5a6a1f09250a207359535399fedbbb4ff
commit r10-11352-g14cb8af5a6a1f09250a207359535399fedbbb4ff
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Dec 22 12:44:13 2022 +0100
cse: Fix up CSE const_anchor handling [PR108193]
The following testcase ICEs on aarch64, because insert_const_anchor
inserts invalid CONST_INT into the CSE tables - 0x80000000 for SImode.
The second hunk of the patch fixes that, the first one is to avoid
triggering undefined behavior at compile time during compute_const_anchors
computations - performing those additions and subtractions in
HOST_WIDE_INT means it can overflow for certain constants.
2022-12-22 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/108193
* cse.c (compute_const_anchors): Change n type to
unsigned HOST_WIDE_INT, adjust comparison against it to avoid
warnings. Formatting fix.
(insert_const_anchor): Use gen_int_mode instead of GEN_INT.
* gfortran.dg/pr108193.f90: New test.
(cherry picked from commit 0cb5d7cdbab8e5f8359764ef5f62d93c2bc88552)
Diff:
---
gcc/cse.c | 10 +++++-----
gcc/testsuite/gfortran.dg/pr108193.f90 | 24 ++++++++++++++++++++++++
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/gcc/cse.c b/gcc/cse.c
index f69a33a82e0..7253b7caf6c 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -1190,14 +1190,14 @@ compute_const_anchors (rtx cst,
HOST_WIDE_INT *lower_base, HOST_WIDE_INT *lower_offs,
HOST_WIDE_INT *upper_base, HOST_WIDE_INT *upper_offs)
{
- HOST_WIDE_INT n = INTVAL (cst);
+ unsigned HOST_WIDE_INT n = UINTVAL (cst);
*lower_base = n & ~(targetm.const_anchor - 1);
- if (*lower_base == n)
+ if ((unsigned HOST_WIDE_INT) *lower_base == n)
return false;
- *upper_base =
- (n + (targetm.const_anchor - 1)) & ~(targetm.const_anchor - 1);
+ *upper_base = ((n + (targetm.const_anchor - 1))
+ & ~(targetm.const_anchor - 1));
*upper_offs = n - *upper_base;
*lower_offs = n - *lower_base;
return true;
@@ -1214,7 +1214,7 @@ insert_const_anchor (HOST_WIDE_INT anchor, rtx reg, HOST_WIDE_INT offs,
rtx anchor_exp;
rtx exp;
- anchor_exp = GEN_INT (anchor);
+ anchor_exp = gen_int_mode (anchor, mode);
hash = HASH (anchor_exp, mode);
elt = lookup (anchor_exp, hash, mode);
if (!elt)
diff --git a/gcc/testsuite/gfortran.dg/pr108193.f90 b/gcc/testsuite/gfortran.dg/pr108193.f90
new file mode 100644
index 00000000000..3a3655f1248
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108193.f90
@@ -0,0 +1,24 @@
+! PR rtl-optimization/108193
+! { dg-do compile { target pthread } }
+! { dg-options "-O2 -fsplit-loops -ftree-parallelize-loops=2 -fno-tree-dominator-opts" }
+
+subroutine foo (n, r)
+ implicit none
+ integer :: i, j, n
+ real :: s, r(*)
+
+ s = 0.0
+
+ do j = 1, 2
+ do i = j, n
+ s = r(i)
+ end do
+ end do
+
+ do i = 1, n
+ do j = i, n
+ s = s + 1
+ end do
+ r(i) = s
+ end do
+end subroutine foo
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-03 15:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-03 15:20 [gcc r10-11352] cse: Fix up CSE const_anchor handling [PR108193] 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).