diff mbox

Fix up vector CONSTRUCTOR verification ICE (PR tree-optimization/54889)

Message ID 20121012181602.GS584@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Oct. 12, 2012, 6:16 p.m. UTC
Hi!

Apparently vectorizable_load is another spot that could create vector
CONSTRUCTORs that wouldn't pass the new CONSTRUCTOR verification.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2012-10-11  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/54889
	* tree-vect-stmts.c (vectorizable_load): Add VIEW_CONVERT_EXPR if
	newref doesn't have compatible type with vectype element type.

	* gfortran.dg/pr54889.f90: New test.


	Jakub

Comments

Richard Biener Oct. 15, 2012, 8:38 a.m. UTC | #1
On Fri, Oct 12, 2012 at 8:16 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Apparently vectorizable_load is another spot that could create vector
> CONSTRUCTORs that wouldn't pass the new CONSTRUCTOR verification.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk?

You should only need this on the ARRAY_REF path (I wonder what are
the types that have a mismatch?), for MEM_REF simply use
build2 (MEM_REF, TREE_TYPE (vectype), ...).

Ok with that change.

Thanks,
Richard.

> 2012-10-11  Jakub Jelinek  <jakub@redhat.com>
>
>         PR tree-optimization/54889
>         * tree-vect-stmts.c (vectorizable_load): Add VIEW_CONVERT_EXPR if
>         newref doesn't have compatible type with vectype element type.
>
>         * gfortran.dg/pr54889.f90: New test.
>
> --- gcc/tree-vect-stmts.c.jj    2012-10-03 09:01:36.000000000 +0200
> +++ gcc/tree-vect-stmts.c       2012-10-11 10:38:38.920249396 +0200
> @@ -4752,6 +4752,11 @@ vectorizable_load (gimple stmt, gimple_s
>                                  running_off,
>                                  TREE_OPERAND (ref, 1));
>
> +             if (!useless_type_conversion_p (TREE_TYPE (vectype),
> +                                             TREE_TYPE (newref)))
> +               newref = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (vectype),
> +                                newref);
> +
>               newref = force_gimple_operand_gsi (gsi, newref, true,
>                                                  NULL_TREE, true,
>                                                  GSI_SAME_STMT);
> --- gcc/testsuite/gfortran.dg/pr54889.f90.jj    2012-10-11 10:58:11.982284176 +0200
> +++ gcc/testsuite/gfortran.dg/pr54889.f90       2012-10-11 10:59:14.283920937 +0200
> @@ -0,0 +1,10 @@
> +! PR tree-optimization/54889
> +! { dg-do compile }
> +! { dg-options "-O3" }
> +! { dg-additional-options "-mavx" { target { i?86-*-* x86_64-*-* } } }
> +
> +subroutine foo(x,y,z)
> +  logical, pointer :: x(:,:)
> +  integer :: y, z
> +  x=x(1:y,1:z)
> +end subroutine
>
>         Jakub
diff mbox

Patch

--- gcc/tree-vect-stmts.c.jj	2012-10-03 09:01:36.000000000 +0200
+++ gcc/tree-vect-stmts.c	2012-10-11 10:38:38.920249396 +0200
@@ -4752,6 +4752,11 @@  vectorizable_load (gimple stmt, gimple_s
 				 running_off,
 				 TREE_OPERAND (ref, 1));
 
+	      if (!useless_type_conversion_p (TREE_TYPE (vectype),
+					      TREE_TYPE (newref)))
+		newref = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (vectype),
+				 newref);
+
 	      newref = force_gimple_operand_gsi (gsi, newref, true,
 						 NULL_TREE, true,
 						 GSI_SAME_STMT);
--- gcc/testsuite/gfortran.dg/pr54889.f90.jj	2012-10-11 10:58:11.982284176 +0200
+++ gcc/testsuite/gfortran.dg/pr54889.f90	2012-10-11 10:59:14.283920937 +0200
@@ -0,0 +1,10 @@ 
+! PR tree-optimization/54889
+! { dg-do compile }
+! { dg-options "-O3" }
+! { dg-additional-options "-mavx" { target { i?86-*-* x86_64-*-* } } }
+
+subroutine foo(x,y,z)
+  logical, pointer :: x(:,:)
+  integer :: y, z
+  x=x(1:y,1:z)
+end subroutine