aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2013-03-20 16:16:09 +0100
committerMarc Glisse <glisse@gcc.gnu.org>2013-03-20 15:16:09 +0000
commit1fc5eced1bd73eef1975f803279b799f4b47c879 (patch)
treec9c12c6936ec99c0dba644b250e5f40d506ee777 /gcc/fold-const.c
parent22c4c8694927961d5884eeab71a17b92aa4f9702 (diff)
downloadgcc-1fc5eced1bd73eef1975f803279b799f4b47c879.zip
gcc-1fc5eced1bd73eef1975f803279b799f4b47c879.tar.gz
gcc-1fc5eced1bd73eef1975f803279b799f4b47c879.tar.bz2
re PR tree-optimization/56355 (abs and multiplication)
2013-03-20 Marc Glisse <marc.glisse@inria.fr> PR tree-optimization/56355 gcc/ * fold-const.c (tree_binary_nonnegative_warnv_p) <MULT_EXPR>: Also handle integers with undefined overflow. gcc/testsuite/ * gcc.dg/pr56355-1.c: New file. From-SVN: r196829
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index de7117e..ae03938 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -15294,15 +15294,18 @@ tree_binary_nonnegative_warnv_p (enum tree_code code, tree type, tree op0,
break;
case MULT_EXPR:
- if (FLOAT_TYPE_P (type))
+ if (FLOAT_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
{
- /* x * x for floating point x is always non-negative. */
- if (operand_equal_p (op0, op1, 0))
- return true;
- return (tree_expr_nonnegative_warnv_p (op0,
- strict_overflow_p)
- && tree_expr_nonnegative_warnv_p (op1,
- strict_overflow_p));
+ /* x * x is always non-negative for floating point x
+ or without overflow. */
+ if (operand_equal_p (op0, op1, 0)
+ || (tree_expr_nonnegative_warnv_p (op0, strict_overflow_p)
+ && tree_expr_nonnegative_warnv_p (op1, strict_overflow_p)))
+ {
+ if (TYPE_OVERFLOW_UNDEFINED (type))
+ *strict_overflow_p = true;
+ return true;
+ }
}
/* zero_extend(x) * zero_extend(y) is non-negative if x and y are