This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] tree-vrp.c: Pick up a constant from an assertion.
- From: Jeffrey A Law <law at redhat dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, dnovillo at redhat dot com
- Date: Thu, 14 Apr 2005 09:18:37 -0600
- Subject: Re: [patch] tree-vrp.c: Pick up a constant from an assertion.
- Organization: Red Hat, Inc
- References: <20050414.090543.74727854.kazu@cs.umass.edu>
- Reply-to: law at redhat dot com
On Thu, 2005-04-14 at 09:05 -0400, Kazu Hirata wrote:
> Attached is a patch to improve VRP by picking up a range from an
> expression that maybe_add_assert_expr inserts.
>
> If we see an "if" statement of the form
>
> if (a == 123)
>
> We insert "a = 123;" into the "then" arm of the "if" statement
> so that the propagation engine can pick up range [123, 123].
>
> The problem is that the propagation engine does not pick up a range
> from "a = 123;". Instead it thinks that the value of 'a' is
> VR_VARYING.
>
> The patch fixes this problem by noticing an assignment of an integer
> constant into an SSA_NAME to create an appropriate VR_RANGE.
>
> With the current pass ordering, the number of COND_EXPRs that VRP
> folds into unconditional jumps stays the same while compiling cc1-i
> files, with or without this patch. I guess this kind of opportunity
> is easily taken by DOM.
Yes. DOM catches this case trivially as it's just a constant
propagation where the set is implicitly derived from the
COND_EXPR. There's definitely value in recording these
equivalencies, so adding this to VRP is a "good thing".
jeff