[PATCH] Fix VRP ICE on x >> cst1; if (x cmp cst2) (PR tree-optimization/53058)
Jakub Jelinek
jakub@redhat.com
Mon Apr 23 23:01:00 GMT 2012
Hi!
My PR52533 patch fixed unsigned comparisons, but not signed ones
where the maximum is different.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?
2012-04-23 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/53058
* tree-vrp.c (register_edge_assert_for_2): Compare mask
for LE_EXPR or GT_EXPR with TYPE_MAX_VALUE of TREE_TYPE (val)
instead of all ones in the precision.
* gcc.c-torture/compile/pr53058.c: New test.
--- gcc/tree-vrp.c.jj 2012-04-23 11:11:21.000000000 +0200
+++ gcc/tree-vrp.c 2012-04-23 16:08:43.752462433 +0200
@@ -4565,6 +4565,7 @@ register_edge_assert_for_2 (tree name, e
&& INTEGRAL_TYPE_P (TREE_TYPE (name2))
&& IN_RANGE (tree_low_cst (cst2, 1), 1, prec - 1)
&& prec <= 2 * HOST_BITS_PER_WIDE_INT
+ && prec == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (val)))
&& live_on_edge (e, name2)
&& !has_single_use (name2))
{
@@ -4598,8 +4599,10 @@ register_edge_assert_for_2 (tree name, e
new_val = val2;
else
{
+ double_int maxval
+ = tree_to_double_int (TYPE_MAX_VALUE (TREE_TYPE (val)));
mask = double_int_ior (tree_to_double_int (val2), mask);
- if (double_int_minus_one_p (double_int_sext (mask, prec)))
+ if (double_int_equal_p (mask, maxval))
new_val = NULL_TREE;
else
new_val = double_int_to_tree (TREE_TYPE (val2), mask);
--- gcc/testsuite/gcc.c-torture/compile/pr53058.c.jj 2012-04-23 15:53:41.489982650 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr53058.c 2012-04-23 15:53:13.000000000 +0200
@@ -0,0 +1,12 @@
+/* PR tree-optimization/53058 */
+
+int a, b, c;
+
+void
+foo ()
+{
+ c = b >> 16;
+ if (c > 32767)
+ c = 0;
+ a = b;
+}
Jakub
More information about the Gcc-patches
mailing list