aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr113396.c19
-rw-r--r--gcc/tree-dfa.cc6
2 files changed, 23 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr113396.c b/gcc/testsuite/gcc.dg/torture/pr113396.c
new file mode 100644
index 0000000..585f717
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr113396.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+
+unsigned char m[] = {5, 79, 79, 79, 79};
+__int128 p;
+int main()
+{
+ int g1 = 0;
+ p = 0;
+ for (int aj = 0; aj < 256; aj++)
+ {
+ m[0] = -4;
+ for (; p >= 0; p -= 1) {
+ g1 = m[p];
+ }
+ }
+ if (g1 != 0xfc)
+ __builtin_abort();
+}
diff --git a/gcc/tree-dfa.cc b/gcc/tree-dfa.cc
index cbd3774..93e53b2 100644
--- a/gcc/tree-dfa.cc
+++ b/gcc/tree-dfa.cc
@@ -549,7 +549,8 @@ get_ref_base_and_extent (tree exp, poly_int64 *poffset,
/* Try to constrain maxsize with range information. */
offset_int omax
= offset_int::from (max, TYPE_SIGN (TREE_TYPE (index)));
- if (known_lt (lbound, omax))
+ if (wi::get_precision (max) <= ADDR_MAX_BITSIZE
+ && known_lt (lbound, omax))
{
poly_offset_int rmaxsize;
rmaxsize = (omax - lbound + 1)
@@ -567,7 +568,8 @@ get_ref_base_and_extent (tree exp, poly_int64 *poffset,
/* Try to adjust bit_offset with range information. */
offset_int omin
= offset_int::from (min, TYPE_SIGN (TREE_TYPE (index)));
- if (known_le (lbound, omin))
+ if (wi::get_precision (min) <= ADDR_MAX_BITSIZE
+ && known_le (lbound, omin))
{
poly_offset_int woffset
= wi::sext (omin - lbound,