This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR70497, missed "subreg" CSE on GIMPLE
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 10 May 2016 16:53:35 -0700
- Subject: Re: [PATCH] Fix PR70497, missed "subreg" CSE on GIMPLE
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1605091444000 dot 18037 at t29 dot fhfr dot qr>
On Mon, May 9, 2016 at 5:59 AM, Richard Biener <rguenther@suse.de> wrote:
>
> The following patch implements CSEing of "subreg" reads from memory
> like (from the testcase in the PR)
>
> union U { int i[16]; char c; };
>
> char foo(int i)
> {
> union U u;
> u.i[0] = i;
> return u.c;
> }
>
> CSEing u.c as (char)i and thus removing u during GIMPLE optimizations.
>
> The patch always goes via generating BIT_FIELD_REFs and letting them
> be simplified via the match-and-simplify machinery. This means it
> replaces handling of complex component and vector extracts we've been
> able to do before.
>
> I didn't restrict the kind of BIT_FIELD_REFs much apart from requiring
> byte-size accesses. I did inspect code generated on powerpc (big-endian)
> for the testcase though (also to verify any endianess issues) and didn't
> spot anything wrong (even for non-lowpart "subregs").
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> Richard.
>
> 2016-05-09 Richard Biener <rguenther@suse.de>
>
> PR tree-optimization/70497
> * tree-ssa-sccvn.c (vn_nary_build_or_lookup): New function
> split out from ...
> (visit_reference_op_load): ... here.
> (vn_reference_lookup_3): Use it to handle subreg-like accesses
> with simplified BIT_FIELD_REFs.
> * tree-ssa-pre.c (eliminate_insert): Handle inserting BIT_FIELD_REFs.
> * tree-complex.c (extract_component): Handle BIT_FIELD_REFs
> correctly.
>
> * gcc.dg/torture/20160404-1.c: New testcase.
> * gcc.dg/tree-ssa/ssa-fre-54.c: Likewise.
>
This caused:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71055
H.J.