diff options
author | Andrew Pinski <pinskia@physics.uc.edu> | 2005-11-26 22:18:04 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2005-11-26 14:18:04 -0800 |
commit | 37d3243dadc9c18a234d04716873b717efa93ae8 (patch) | |
tree | 74cae8a39ab44003fc82853af062e2e770ed36f8 /gcc/fold-const.c | |
parent | cd16503aa2153cf1e3d376eabe4ec88aacac968a (diff) | |
download | gcc-37d3243dadc9c18a234d04716873b717efa93ae8.zip gcc-37d3243dadc9c18a234d04716873b717efa93ae8.tar.gz gcc-37d3243dadc9c18a234d04716873b717efa93ae8.tar.bz2 |
re PR middle-end/23669 (fold does convert (-a)/10 into a/-10 with -fno-wrapv)
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 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.
From-SVN: r107543
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 59037d5..63f1294 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8440,6 +8440,19 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && 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. |