[PATCH] Fix vectorizer bool pattern matching with -fnon-call-exceptions (PR tree-optimization/52046)
Richard Guenther
richard.guenther@gmail.com
Mon Jan 30 13:41:00 GMT 2012
On Mon, Jan 30, 2012 at 2:37 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> If a comparison can throw, it won't be a valid condition for
> COND_EXPR or VEC_COND_EXPR, because is_gimple_condexpr will
> fail. This patch gives up in that case. Bootstrapped/regtested on
> x86_64-linux and i686-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2012-01-30 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/52046
> * tree-vect-patterns.c (check_bool_pattern): Give up if
> a comparison could throw.
>
> * gcc.dg/pr52046.c: New test.
>
> --- gcc/tree-vect-patterns.c.jj 2012-01-13 21:47:35.000000000 +0100
> +++ gcc/tree-vect-patterns.c 2012-01-30 10:58:11.048787682 +0100
> @@ -1,5 +1,5 @@
> /* Analysis Utilities for Loop Vectorization.
> - Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
> + Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
> Free Software Foundation, Inc.
> Contributed by Dorit Nuzman <dorit@il.ibm.com>
>
> @@ -1967,6 +1967,11 @@ check_bool_pattern (tree var, loop_vec_i
> {
> tree vecitype, comp_vectype;
>
> + /* If the comparison can throw, then is_gimple_condexpr will be
> + false and we can't make a COND_EXPR/VEC_COND_EXPR out of it. */
> + if (stmt_could_throw_p (def_stmt))
> + return false;
> +
> comp_vectype = get_vectype_for_scalar_type (TREE_TYPE (rhs1));
> if (comp_vectype == NULL_TREE)
> return false;
> --- gcc/testsuite/gcc.dg/pr52046.c.jj 2012-01-30 10:59:42.749264286 +0100
> +++ gcc/testsuite/gcc.dg/pr52046.c 2012-01-30 10:59:28.000000000 +0100
> @@ -0,0 +1,14 @@
> +/* PR tree-optimization/52046 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -fexceptions -fnon-call-exceptions" } */
> +
> +extern float a[], b[], c[], d[];
> +extern int k[];
> +
> +void
> +foo (void)
> +{
> + int i;
> + for (i = 0; i < 1024; ++i)
> + k[i] = (a[i] < b[i]) | (c[i] < d[i]);
> +}
>
> Jakub
More information about the Gcc-patches
mailing list