This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Don't consider TREE_OVERFLOW in folding of comparisons with highest/lowest type's value (PR tree-optimization/37664)
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Jakub Jelinek" <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 16 Oct 2008 11:35:20 +0200
- Subject: Re: [PATCH] Don't consider TREE_OVERFLOW in folding of comparisons with highest/lowest type's value (PR tree-optimization/37664)
- References: <20081016070812.GD30239@tyan-ft48-01.lab.bos.redhat.com>
On Thu, Oct 16, 2008 at 9:08 AM, Jakub Jelinek <email@example.com> wrote:
> 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 <firstname.lastname@example.org>
> 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;
> +foo ()
> + int a = 0x8899A862;
> + int b = 0x8E * a;
> + int c = (b % b);
> + if (v > (4294967295U >> c))
> + return v;
> + return 0;