aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/gimple-fold.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr98255.c49
-rw-r--r--gcc/tree-dfa.c6
-rw-r--r--gcc/tree-ssa-sccvn.c2
4 files changed, 54 insertions, 5 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index fe46d98..de5a6c2 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -8007,7 +8007,7 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree))
poly_offset_int woffset
= wi::sext (wi::to_poly_offset (idx)
- wi::to_poly_offset (low_bound),
- TYPE_PRECISION (TREE_TYPE (idx)));
+ TYPE_PRECISION (sizetype));
woffset *= tree_to_uhwi (unit_size);
woffset *= BITS_PER_UNIT;
if (woffset.to_shwi (&offset))
diff --git a/gcc/testsuite/gcc.dg/pr98255.c b/gcc/testsuite/gcc.dg/pr98255.c
new file mode 100644
index 0000000..5cbed68
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr98255.c
@@ -0,0 +1,49 @@
+/* PR tree-optimization/98255 */
+/* { dg-do run } */
+/* { dg-options "-Os" } */
+/* { dg-additional-options "-fPIC" { target fpic } } */
+
+struct A { volatile unsigned b; unsigned c; };
+int d, *e, h, k, l;
+static struct A f;
+long g;
+static unsigned i = -2U;
+volatile int j;
+
+long
+foo (void)
+{
+ char n[4][4][3]
+ = { { {9, 2, 8}, {9, 2, 8}, {9, 2, 8}, {9} }, { {8} }, { {8} }, { {2} } };
+ while (d)
+ {
+ for (; f.c < 4; f.c++)
+ {
+ *e = 0;
+ h = n[f.c + 4][0][d];
+ }
+ while (g)
+ return n[0][3][i];
+ while (1)
+ {
+ if (k)
+ {
+ j = 0;
+ if (j)
+ continue;
+ }
+ if (l)
+ break;
+ }
+ }
+ return 0;
+}
+
+int
+main ()
+{
+ asm volatile ("" : "+g" (d), "+g" (g), "+g" (f.c));
+ asm volatile ("" : "+g" (e), "+g" (k), "+g" (l));
+ foo ();
+ return 0;
+}
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index 648fdd0..0482b05 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -503,7 +503,7 @@ get_ref_base_and_extent (tree exp, poly_int64_pod *poffset,
poly_offset_int woffset
= wi::sext (wi::to_poly_offset (index)
- wi::to_poly_offset (low_bound),
- TYPE_PRECISION (TREE_TYPE (index)));
+ TYPE_PRECISION (sizetype));
woffset *= wi::to_offset (unit_size);
woffset <<= LOG2_BITS_PER_UNIT;
bit_offset += woffset;
@@ -564,7 +564,7 @@ get_ref_base_and_extent (tree exp, poly_int64_pod *poffset,
{
poly_offset_int woffset
= wi::sext (omin - lbound,
- TYPE_PRECISION (TREE_TYPE (index)));
+ TYPE_PRECISION (sizetype));
woffset *= wi::to_offset (unit_size);
woffset <<= LOG2_BITS_PER_UNIT;
bit_offset += woffset;
@@ -822,7 +822,7 @@ get_addr_base_and_unit_offset_1 (tree exp, poly_int64_pod *poffset,
poly_offset_int woffset
= wi::sext (wi::to_poly_offset (index)
- wi::to_poly_offset (low_bound),
- TYPE_PRECISION (TREE_TYPE (index)));
+ TYPE_PRECISION (sizetype));
woffset *= wi::to_offset (unit_size);
byte_offset += woffset.force_shwi ();
}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 588f1b8..d45aee8 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1108,7 +1108,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref,
poly_offset_int woffset
= wi::sext (wi::to_poly_offset (op->op0)
- wi::to_poly_offset (op->op1),
- TYPE_PRECISION (TREE_TYPE (op->op0)));
+ TYPE_PRECISION (sizetype));
woffset *= wi::to_offset (op->op2) * vn_ref_op_align_unit (op);
woffset <<= LOG2_BITS_PER_UNIT;
offset += woffset;