summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-27 21:31:36 +0000
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-27 21:31:36 +0000
commit212f6d6d5ed26eb3192806ee6bfe9ee11ff65348 (patch)
treeb7fdf4f01178be8199203636f4b7c9cb41de7ae9 /gcc/fold-const.c
parent065b42aa8a350788ab6c21c754bbbe9b63a97467 (diff)
downloadgcc-212f6d6d5ed26eb3192806ee6bfe9ee11ff65348.tar.gz
2005-11-27 Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/24575 * fold-const.c (negate_expr_p): Add case for signed divides if overflow is undefined. (negate_expr): Likewise. 2005-11-27 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/24575 * gcc.dg/tree-ssa/divide-3.c: New test. * gcc.dg/tree-ssa/divide-4.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107575 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 63f12949ab7..45863ee77e3 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -991,6 +991,16 @@ negate_expr_p (tree t)
|| negate_expr_p (TREE_OPERAND (t, 0));
break;
+ case TRUNC_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case CEIL_DIV_EXPR:
+ case EXACT_DIV_EXPR:
+ if (TYPE_UNSIGNED (TREE_TYPE (t)) || flag_wrapv)
+ break;
+ return negate_expr_p (TREE_OPERAND (t, 1))
+ || negate_expr_p (TREE_OPERAND (t, 0));
+
case NOP_EXPR:
/* Negate -((double)float) as (double)(-float). */
if (TREE_CODE (type) == REAL_TYPE)
@@ -1132,6 +1142,28 @@ negate_expr (tree t)
}
break;
+ case TRUNC_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case CEIL_DIV_EXPR:
+ case EXACT_DIV_EXPR:
+ if (!TYPE_UNSIGNED (TREE_TYPE (t)) && !flag_wrapv)
+ {
+ tem = TREE_OPERAND (t, 1);
+ if (negate_expr_p (tem))
+ return fold_convert (type,
+ fold_build2 (TREE_CODE (t), TREE_TYPE (t),
+ TREE_OPERAND (t, 0),
+ negate_expr (tem)));
+ tem = TREE_OPERAND (t, 0);
+ if (negate_expr_p (tem))
+ return fold_convert (type,
+ fold_build2 (TREE_CODE (t), TREE_TYPE (t),
+ negate_expr (tem),
+ TREE_OPERAND (t, 1)));
+ }
+ break;
+
case NOP_EXPR:
/* Convert -((double)float) into (double)(-float). */
if (TREE_CODE (type) == REAL_TYPE)