This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't consider TREE_OVERFLOW in folding of comparisons with highest/lowest type's value (PR tree-optimization/37664)


Hi!

On this testcase, VRP is upset by (unsigned int) x > UINT_MAX (OVF),
for ASSERT_EXPR it clears the TREE_OVERFLOW flag (since PR37327)
and then ICEs because this ASSERT_EXPR's condition folds to boolean_false_node.
Is there any reason why fold prohibits folding of comparisons with
highest or lowest type's value if the value has TREE_OVERFLOW set?
I've tried to construct a testcase where C/C++ would care, but if one
of the arguments has TREE_OVERFLOW set, then the warning/error is reported
already when folding that value, not when folding the comparison.
This passed bootstrap/regtest, so if it matters, it doesn't reproduce
on anything we have in the tree.

Ok for trunk?

2008-10-16  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/37664
	* fold-const.c (fold_binary): When optimizing comparison with
	highest or lowest type's value, don't consider TREE_OVERFLOW.

	* gcc.c-torture/compile/pr37664.c: New test.

--- gcc/fold-const.c.jj	2008-09-30 16:57:11.000000000 +0200
+++ gcc/fold-const.c	2008-10-16 01:02:42.000000000 +0200
@@ -12447,7 +12447,6 @@ fold_binary (enum tree_code code, tree t
 	unsigned int width = TYPE_PRECISION (arg1_type);
 
 	if (TREE_CODE (arg1) == INTEGER_CST
-	    && !TREE_OVERFLOW (arg1)
 	    && width <= 2 * HOST_BITS_PER_WIDE_INT
 	    && (INTEGRAL_TYPE_P (arg1_type) || POINTER_TYPE_P (arg1_type)))
 	  {
--- gcc/testsuite/gcc.c-torture/compile/pr37664.c.jj	2008-10-15 14:14:23.000000000 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr37664.c	2008-10-15 14:14:04.000000000 +0200
@@ -0,0 +1,14 @@
+/* PR tree-optimization/37664 */
+
+int v;
+
+int
+foo ()
+{
+  int a = 0x8899A862;
+  int b = 0x8E * a;
+  int c = (b % b);
+  if (v > (4294967295U >> c))
+    return v;
+  return 0;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]