Swap the order of scale and base for calculating the array index.

fold_constants doesn't like dags very much, but it can do the right thing
if the expressions are in the right order. This is merely a workaround
until I get to work on the code generator itself.
This commit is contained in:
Bill Currie 2011-01-10 12:19:44 +09:00
parent 5864c198cc
commit cd38bd71fa

View file

@ -2304,8 +2304,9 @@ array_expr (expr_t *array, expr_t *index)
scale->e.integer_val = size;
index = binary_expr ('*', index, scale);
index = binary_expr ('-', index,
binary_expr ('*', scale,
new_integer_expr (array_type->t.array.base)));
binary_expr ('*',
new_integer_expr (array_type->t.array.base),
scale));
index = fold_constants (index);
if ((index->type == ex_integer
&& index->e.integer_val < 32768 && index->e.integer_val >= -32768)