+2005-11-26 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR middle-end/23669
+ * fold-const.c (fold_binary): Convert -A/-B to A/B for signed types
+ when overflow is undefined.
+
2005-11-26 Hans-Peter Nilsson <hp@axis.com>
* doc/md.texi (Insn Canonicalizations): Refer to the
&& TREE_INT_CST_HIGH (arg1) == -1)
return fold_convert (type, negate_expr (arg0));
+ /* Convert -A / -B to A / B when the type is signed and overflow is
+ undefined. */
+ if (!TYPE_UNSIGNED (type) && !flag_wrapv
+ && TREE_CODE (arg0) == NEGATE_EXPR
+ && negate_expr_p (arg1))
+ return fold_build2 (code, type, TREE_OPERAND (arg0, 0),
+ negate_expr (arg1));
+ if (!TYPE_UNSIGNED (type) && !flag_wrapv
+ && TREE_CODE (arg1) == NEGATE_EXPR
+ && negate_expr_p (arg0))
+ return fold_build2 (code, type, negate_expr (arg0),
+ TREE_OPERAND (arg1, 0));
+
/* If arg0 is a multiple of arg1, then rewrite to the fastest div
operation, EXACT_DIV_EXPR.
+2005-11-26 Andrew Pinski <pinskia@physics.uc.edu>
+
+ PR middle-end/23669
+ * gcc.dg/tree-ssa/divide-1.c: New test.
+ * gcc.dg/tree-ssa/divide-2.c: New test.
+
2005-11-26 Janne Blomqvist <jb@gcc.gnu.org>
PR libgfortran/24945
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+
+int f(int a)
+{
+ return (-a)/10;
+}
+
+
+/* { dg-final { scan-tree-dump-times "-a / 10" 0 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "a / -10" 1 "optimized"} } */
+
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+
+int f(int a)
+{
+ return 10/-a;
+}
+
+
+/* { dg-final { scan-tree-dump-times "10 / -a" 0 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "-10 / a" 1 "optimized"} } */
+
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+