This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR 52631 (VN does not use simplified expression for lookup)
- From: Andrew Pinski <andrew dot pinski at caviumnetworks dot com>
- To: Richard Guenther <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 19 Aug 2012 21:49:53 -0700
- Subject: Re: [PATCH] Fix PR 52631 (VN does not use simplified expression for lookup)
- References: <CA+=Sn1nE=aAEWmLCu_-QLqevzXHbBZLzxPp0SKhNsRo1ajM9KA@mail.gmail.com> <CAFiYyc08R2FduOjPDCJ4Q2J1vZx-+eL9CQci2_xCtGS6A3Sz3g@mail.gmail.com>
On Wed, Jul 25, 2012 at 4:39 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Tue, Jul 24, 2012 at 5:50 PM, Andrew Pinski
> <andrew.pinski@caviumnetworks.com> wrote:
>> Hi,
>> Before tuples was introduced, VN used to lookup the simplified
>> expression to see if it was available already and use that instead of
>> the non simplified one. This patch adds the support back to VN to do
>> exactly that.
>>
>> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
>
> I think this should be done for all RHS and SSA name LHS, not only
> for UNARY/BINARY/TERNARY - because even for SINGLE rhs we
> can end up simplifying (for REALPART_EXPR for example which we
> handle as nary, too). I think we constrain try_to_simplify enough
> so that
>
> + /* First try to lookup the simplified expression. */
> + if (simplified && valid_gimple_rhs_p (simplified))
> + {
> + tree result = vn_nary_op_lookup (simplified, NULL);
> + if (result)
> + {
> + changed = set_ssa_val_to (lhs, result);
> + goto done;
> + }
> + changed = set_ssa_val_to (lhs, lhs);
> + vn_nary_op_insert (simplified, lhs);
> + }
> switch (get_gimple_rhs_class (code))
> {
> case GIMPLE_UNARY_RHS:
> case GIMPLE_BINARY_RHS:
> ...
>
> should work. As you also insert the simplified variant I think we really
> (finally) want to have a valid_nary_op routine rather than relying on
> valid_gimple_rhs_p which is way too generic.
I don't see valid_gimple_rhs_p being that generic as it checks to make
sure the operands of the gimple are valid.
Maybe I am missing something here though.
Thanks,
Andrew Pinski
>
> Thanks,
> Richard.
>
>> Thanks,
>> Andrew Pinski
>>
>> ChangeLog:
>>
>> * tree-ssa-sccvn.c (visit_use): Look up the simplified
>> expression before visting the original one.
>>
>> * gcc.dg/tree-ssa/ssa-fre-9.c: Update the number of
>> eliminatations that happen.