aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2013-12-02 11:20:14 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2013-12-02 11:20:14 +0000
commit139bd704f15614f21dc1113235cc5bd2dd81238f (patch)
tree8996b3856e8b5fe78d5f8abc322cbffb9f59af6c /gcc
parent95044b50b030259b37c187862dca756ea58ef08a (diff)
downloadgcc-139bd704f15614f21dc1113235cc5bd2dd81238f.zip
gcc-139bd704f15614f21dc1113235cc5bd2dd81238f.tar.gz
gcc-139bd704f15614f21dc1113235cc5bd2dd81238f.tar.bz2
re PR tree-optimization/59356 (ACATS C52102A and C52102C failures)
PR tree-optimization/59356 * tree-dfa.h (get_addr_base_and_unit_offset_1) <case ARRAY_REF>: Do the offset computation using the precision of the index type. From-SVN: r205585
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/opt30.adb20
-rw-r--r--gcc/tree-dfa.h10
4 files changed, 35 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cb8edae..78554aa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-02 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR tree-optimization/59356
+ * tree-dfa.h (get_addr_base_and_unit_offset_1) <case ARRAY_REF>: Do the
+ offset computation using the precision of the index type.
+
2013-12-02 Yvan Roux <yvan.roux@linaro.org>
PR target/58785
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 01a160e..c688c80 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-02 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/opt30.adb: New test.
+
2013-12-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/57354
diff --git a/gcc/testsuite/gnat.dg/opt30.adb b/gcc/testsuite/gnat.dg/opt30.adb
new file mode 100644
index 0000000..12139c5
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt30.adb
@@ -0,0 +1,20 @@
+-- { dg-do run }
+-- { dg-options "-O" }
+
+procedure Opt30 is
+
+ function Id_I (I : Integer) return Integer is
+ begin
+ return I;
+ end;
+
+ A : array (Integer range -4..4) of Integer;
+
+begin
+ A := (-ID_I(4), -ID_I(3), -ID_I(2), -ID_I(1), ID_I(100),
+ ID_I(1), ID_I(2), ID_I(3), ID_I(4));
+ A(-4..0) := A(0..4);
+ if A /= (100, 1, 2, 3, 4, 1, 2, 3, 4) then
+ raise Program_Error;
+ end if;
+end;
diff --git a/gcc/tree-dfa.h b/gcc/tree-dfa.h
index 7d0a470..71f2c21 100644
--- a/gcc/tree-dfa.h
+++ b/gcc/tree-dfa.h
@@ -102,11 +102,11 @@ get_addr_base_and_unit_offset_1 (tree exp, HOST_WIDE_INT *poffset,
&& (unit_size = array_ref_element_size (exp),
TREE_CODE (unit_size) == INTEGER_CST))
{
- HOST_WIDE_INT hindex = TREE_INT_CST_LOW (index);
-
- hindex -= TREE_INT_CST_LOW (low_bound);
- hindex *= TREE_INT_CST_LOW (unit_size);
- byte_offset += hindex;
+ double_int doffset
+ = (TREE_INT_CST (index) - TREE_INT_CST (low_bound))
+ .sext (TYPE_PRECISION (TREE_TYPE (index)));
+ doffset *= tree_to_double_int (unit_size);
+ byte_offset += doffset.to_shwi ();
}
else
return NULL_TREE;