+2011-08-03 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/49958
+ * fold-const.c (fold_binary_loc): Only associate
+ (+ (+ (* a b) c) (* d e)) as (+ (+ (* a b) (* d e)) c) if
+ overflow wraps.
+
2011-08-03 Alan Modra <amodra@gmail.com>
PR rtl-optimization/49941
/* Reassociate (plus (plus (mult) (foo)) (mult)) as
(plus (plus (mult) (mult)) (foo)) so that we can
take advantage of the factoring cases below. */
- if (((TREE_CODE (arg0) == PLUS_EXPR
- || TREE_CODE (arg0) == MINUS_EXPR)
- && TREE_CODE (arg1) == MULT_EXPR)
- || ((TREE_CODE (arg1) == PLUS_EXPR
- || TREE_CODE (arg1) == MINUS_EXPR)
- && TREE_CODE (arg0) == MULT_EXPR))
+ if (TYPE_OVERFLOW_WRAPS (type)
+ && (((TREE_CODE (arg0) == PLUS_EXPR
+ || TREE_CODE (arg0) == MINUS_EXPR)
+ && TREE_CODE (arg1) == MULT_EXPR)
+ || ((TREE_CODE (arg1) == PLUS_EXPR
+ || TREE_CODE (arg1) == MINUS_EXPR)
+ && TREE_CODE (arg0) == MULT_EXPR)))
{
tree parg0, parg1, parg, marg;
enum tree_code pcode;
+2011-08-03 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/49958
+ * gcc.dg/torture/pr49958.c: New testcase.
+
2011-08-03 Richard Guenther <rguenther@suse.de>
PR tree-optimization/49938
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-fstrict-overflow" } */
+
+extern void abort (void);
+int foo (int i, int j, int o, int m) { return i*o + 1 + j*m > 1; }
+int main()
+{
+ if (foo (- __INT_MAX__ - 1, -1, 1, 1))
+ abort ();
+ return 0;
+}