on ARRAY_REFs sign-extend offsets only from sizetype's precision [PR98255]
[gcc.git] / gcc / gimple-fold.c
index fe46d987faab657b7d5c2c55a4c637b5bb996070..de5a6c22395d8114000eea7599aba2d4a39f6c6d 100644 (file)
@@ -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))