diff options
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -4546,8 +4546,20 @@ get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode, index_type = TREE_TYPE (index); } + /* Optimize the special-case of a zero lower bound. + + We convert the low_bound to sizetype to avoid some problems + with constant folding. (E.g. suppose the lower bound is 1, + and its mode is QI. Without the conversion, (ARRAY + +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1)) + +INDEX), which becomes (ARRAY+255+INDEX). Oops!) + + But sizetype isn't quite right either (especially if + the lowbound is negative). FIXME */ + if (! integer_zerop (low_bound)) - index = fold (build (MINUS_EXPR, index_type, index, low_bound)); + index = fold (build (MINUS_EXPR, index_type, index, + convert (sizetype, low_bound))); if (TREE_CODE (index) == INTEGER_CST) { |