2006-10-23 Richard Guenther <rguenther@suse.de>
+ PR middle-end/27132
+ PR middle-end/23295
+ * builtins.c (fold_binary): Remove checks for flag_wrapv
+ and flag_trapv where negate_expr_p covers these cases.
+
+2006-10-23 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/29548
+ * fold-const.c (fold_plusminus_mult_expr): Check exact power
+ of two on the absolute value.
+ (fold_binary): Fold x * -C to -x * C if x is easily negatable
+ and negating -C does not overflow.
+
+2006-10-23 Richard Guenther <rguenther@suse.de>
+
PR middle-end/21032
* convert.c (convert_to_real): Fold (float)-x to -(float)x
only if not flag_rounding_math.
else
maybe_same = arg11;
- if (exact_log2 (int11) > 0 && int01 % int11 == 0)
+ if (exact_log2 (abs (int11)) > 0 && int01 % int11 == 0)
{
alt0 = fold_build2 (MULT_EXPR, TREE_TYPE (arg00), arg00,
build_int_cst (TREE_TYPE (arg00),
/* (-A) - B -> (-B) - A where B is easily negated and we can swap. */
if (TREE_CODE (arg0) == NEGATE_EXPR
&& (FLOAT_TYPE_P (type)
- || (INTEGRAL_TYPE_P (type) && flag_wrapv && !flag_trapv))
+ || INTEGRAL_TYPE_P (type))
&& negate_expr_p (arg1)
&& reorder_operands_p (arg0, arg1))
return fold_build2 (MINUS_EXPR, type, negate_expr (arg1),
/* Avoid this transformation if B is a positive REAL_CST. */
&& (TREE_CODE (arg1) != REAL_CST
|| REAL_VALUE_NEGATIVE (TREE_REAL_CST (arg1))))
- || (INTEGRAL_TYPE_P (type) && flag_wrapv && !flag_trapv)))
+ || INTEGRAL_TYPE_P (type)))
return fold_build2 (PLUS_EXPR, type,
fold_convert (type, arg0),
fold_convert (type, negate_expr (arg1)));
/* Transform x * -1 into -x. */
if (integer_all_onesp (arg1))
return fold_convert (type, negate_expr (arg0));
+ /* Transform x * -C into -x * C if x is easily negatable. */
+ if (TREE_CODE (arg1) == INTEGER_CST
+ && tree_int_cst_sgn (arg1) == -1
+ && negate_expr_p (arg0)
+ && (tem = negate_expr (arg1)) != arg1
+ && !TREE_OVERFLOW (tem))
+ return fold_build2 (MULT_EXPR, type,
+ negate_expr (arg0), tem);
/* (a * (1 << b)) is (a << b) */
if (TREE_CODE (arg1) == LSHIFT_EXPR
2006-10-23 Richard Guenther <rguenther@suse.de>
+ PR middle-end/27132
+ PR middle-end/23295
+ * gcc.dg/pr27132.c: New testcase.
+ * gcc.dg/pr23295.c: Likewise.
+ * gcc.dg/tree-ssa/pr23294.c: Adjust patterns.
+ * g++.dg/tree-ssa/pr19807.C: Likewise.
+
+2006-10-23 Richard Guenther <rguenther@suse.de>
+
PR middle-end/21032
* gcc.dg/pr21032.c: New testcase.
}
/* { dg-final { scan-tree-dump-times "a \\\* 5" 3 "optimized" } } */
-/* { dg-final { scan-tree-dump "\\\(b \\\* 3 \\\+ a\\\) \\\* 2" "optimized" } } */
-/* { dg-final { scan-tree-dump "\\\(a - b \\\* 3\\\) \\\* 2" "optimized" } } */
-/* { dg-final { scan-tree-dump "\\\(a \\\* 3 - b\\\) \\\* 2" "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\\) \\\* 2" 3 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "\\\* 6" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */