===================================================================
@@ -6166,8 +6173,12 @@ extract_muldiv_1 (tree t, tree c, enum t
&& ((sign == UNSIGNED && tcode != MULT_EXPR) || sign == SIGNED))
overflow_p = true;
if (!overflow_p)
- return fold_build2 (tcode, ctype, fold_convert (ctype, op0),
- wide_int_to_tree (ctype, mul));
+ {
+ mul = wide_int::from (mul, TYPE_PRECISION (ctype),
+ TYPE_SIGN (TREE_TYPE (op1)));
+ return fold_build2 (tcode, ctype, fold_convert (ctype, op0),
+ wide_int_to_tree (ctype, mul));
+ }
}
/* If these operations "cancel" each other, we have the main
===================================================================
@@ -0,0 +1,12 @@
+/* { dg-do run } */
+
+short foo[100];
+
+int main()
+{
+ short* bar = &foo[50];
+ short i = 1;
+ short j = 1;
+ short value = bar[8 - i * 2 * j];
+ return value;
+}