This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix up vectorizer cost model use of uninitialized value (PR tree-optimization/52210)
- From: Richard Guenther <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 14 Feb 2012 09:40:47 +0100 (CET)
- Subject: Re: [PATCH] Fix up vectorizer cost model use of uninitialized value (PR tree-optimization/52210)
- References: <20120213193719.GK18768@tyan-ft48-01.lab.bos.redhat.com>
On Mon, 13 Feb 2012, Jakub Jelinek wrote:
> Hi!
>
> The PR50912 changed vect_get_and_check_slp_defs dt from
> array into scalar, which fails when calling vect_model_simple_cost
> which looks at two array members. I believe even 4.6 checked just
> the first operand, as it called it when processing the first operand,
> so IMHO this patch doesn't regress (the very incomplete) cost model
> handling and doesn't introduce undefined behavior.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2012-02-13 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/52210
> * tree-vect-slp.c (vect_get_and_check_slp_defs): Call
> vect_model_simple_cost with two entry vect_def_type array instead
> of an address of dt.
>
> * gcc.dg/pr52210.c: New test.
>
> --- gcc/tree-vect-slp.c.jj 2012-02-07 16:05:51.000000000 +0100
> +++ gcc/tree-vect-slp.c 2012-02-13 10:14:28.017357662 +0100
> @@ -321,10 +321,15 @@ vect_get_and_check_slp_defs (loop_vec_in
> vect_model_store_cost (stmt_info, ncopies_for_cost, false,
> dt, slp_node);
> else
> - /* Not memory operation (we don't call this function for
> - loads). */
> - vect_model_simple_cost (stmt_info, ncopies_for_cost, &dt,
> - slp_node);
> + {
> + enum vect_def_type dts[2];
> + dts[0] = dt;
> + dts[1] = vect_uninitialized_def;
> + /* Not memory operation (we don't call this function for
> + loads). */
> + vect_model_simple_cost (stmt_info, ncopies_for_cost, dts,
> + slp_node);
> + }
> }
> }
> else
> --- gcc/testsuite/gcc.dg/pr52210.c.jj 2012-02-13 10:27:46.692809216 +0100
> +++ gcc/testsuite/gcc.dg/pr52210.c 2012-02-13 10:25:31.000000000 +0100
> @@ -0,0 +1,12 @@
> +/* PR tree-optimization/52210 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3" } */
> +
> +void
> +foo (long *x, long y, long z)
> +{
> + long a = x[0];
> + long b = x[1];
> + x[0] = a & ~y;
> + x[1] = b & ~z;
> +}
>
> Jakub
>
>
--
Richard Guenther <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer