From 94dc53320e6c22ef0d3f8d8db83c2492de001f5b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 29 Apr 2013 09:55:09 +0200 Subject: [PATCH] re PR tree-optimization/57083 (Wrong constant folding) PR tree-optimization/57083 * tree-vrp.c (extract_range_from_binary_expr_1): For LSHIFT_EXPR with non-singleton shift count range, zero extend low_bound for uns case. * gcc.dg/torture/pr57083.c: New test. From-SVN: r198388 --- gcc/ChangeLog | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr57083.c | 15 +++++++++++++++ gcc/tree-vrp.c | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr57083.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 85dfc35..262dbdf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2013-04-29 Jakub Jelinek + PR tree-optimization/57083 + * tree-vrp.c (extract_range_from_binary_expr_1): For LSHIFT_EXPR with + non-singleton shift count range, zero extend low_bound for uns case. + * config/i386/predicates.md (general_vector_operand): New predicate. * config/i386/i386.c (const_vector_equal_evenodd_p): New function. (ix86_expand_mul_widen_evenodd): Force op1 resp. op2 into register diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7e0975d..ddb11ec 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-04-29 Jakub Jelinek + + PR tree-optimization/57083 + * gcc.dg/torture/pr57083.c: New test. + 2013-04-28 Paolo Carlini PR c++/56450 diff --git a/gcc/testsuite/gcc.dg/torture/pr57083.c b/gcc/testsuite/gcc.dg/torture/pr57083.c new file mode 100644 index 0000000..070a53d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57083.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/57083 */ +/* { dg-do run { target int32plus } } */ + +extern void abort (void); +short x = 1; +int y = 0; + +int +main () +{ + unsigned t = (0x7fff8001U - x) << (y == 0); + if (t != 0xffff0000U) + abort (); + return 0; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index cb4a09a..a740907 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2837,7 +2837,7 @@ extract_range_from_binary_expr_1 (value_range_t *vr, if (uns) { - low_bound = bound; + low_bound = bound.zext (prec); high_bound = complement.zext (prec); if (tree_to_double_int (vr0.max).ult (low_bound)) { -- 2.7.4