This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make VRP recognize range tests (unsigned)a + CST <= CST2
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 08 Feb 2007 13:16:01 -0500
- Subject: Re: [PATCH] Make VRP recognize range tests (unsigned)a + CST <= CST2
- References: <Pine.LNX.4.64.0702061352470.3994@zhemvz.fhfr.qr>
Richard Guenther wrote on 02/06/07 07:56:
This patch makes VRP recognize range and anti-range tests. It does so
by allowing more flexible ASSERT_EXPRs (which is neccessary for the
anti-range case) like
ASSERT_EXPR <a_1, (unsigned)a_1 + 5 > 13>
and derive ranges and anti-ranges from such directly.
I don't really like where this is going. VRP does not need more
complexity. Though it triggers 30,000 times more, are there any
perceivable benefits in runtime or code size?
Instead of supporting the more complex expression (unsigned)a_1 + 5 > 13
why not convert that to a_1 > 8? We certainly can ignore the cast.
One thing that I kind of liked about the patch is the extension to the
idea of emitting ASSERTs based on seemingly useless predicates. In one
of your testcases, we have:
i.0_3 = (unsigned int) i_2(D);
D.1974_4 = i.0_3 + 4294967295;
D.1975_5 = D.1974_4 <= 4;
D.1976_7 = k_6(D) > 9;
D.1977_8 = D.1975_5 && D.1976_7;
if (D.1977_8) goto <L0>; else goto <L4>;
<L0>:;
if (k_15 <= 41) goto <L1>; else goto <L4>;
<L1>:;
k_14 = ASSERT_EXPR <k_15, k_15 <= 41>;
D.1978_9 = i_2(D) + k_14;
For i_2, your patch inserts:
i_14 = ASSERT_EXPR <i_2(D), (unsigned int) i_2(D) + 4294967295 <= 4>
since we are already working recursively at finding these comparisons,
why not just canonicalize them?