re PR tree-optimization/54889 (Revision 191983 gives compfail for 465.tonto in SPEC...
authorJakub Jelinek <jakub@redhat.com>
Tue, 16 Oct 2012 11:19:37 +0000 (13:19 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 16 Oct 2012 11:19:37 +0000 (13:19 +0200)
PR tree-optimization/54889
* tree-vect-stmts.c (vectorizable_load): Add VIEW_CONVERT_EXPR if
ARRAY_REF newref doesn't have compatible type with vectype element
type, use vectype element type for MEM_REF.

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

From-SVN: r192493

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr54889.f90 [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 52ef5324cbe004d6cc2dac2f9c5d764d5624fb19..dfbc6118622bb42126e5f716f1d67ab00d1be436 100644 (file)
@@ -1,3 +1,10 @@
+2012-10-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54889
+       * tree-vect-stmts.c (vectorizable_load): Add VIEW_CONVERT_EXPR if
+       ARRAY_REF newref doesn't have compatible type with vectype element
+       type, use vectype element type for MEM_REF.
+
 2012-10-16  Steven Bosscher  <steven@gcc.gnu.org>
 
        * combine.c (record_dead_and_set_regs): Iterate over hard register set
index adeeb3e5e9111660127485e15295374d7328b943..babeba69d485a884c98de26c699a5e19b18bc15d 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54889
+       * gfortran.dg/pr54889.f90: New test.
+
 2012-10-16  Eric Botcazou <ebotcazou@adacore.com>
 
        * g++.dg/other/dump-ada-spec-2.C: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr54889.f90 b/gcc/testsuite/gfortran.dg/pr54889.f90
new file mode 100644 (file)
index 0000000..68c6bee
--- /dev/null
@@ -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
index e1b7b7a0e7b87450b50612bfe44ead433df08287..70bcebbe99bd6bfe757f0a49dd8cc4735337e02a 100644 (file)
@@ -4743,12 +4743,18 @@ vectorizable_load (gimple stmt, gimple_stmt_iterator *gsi, gimple *vec_stmt,
              tree newref, newoff;
              gimple incr;
              if (TREE_CODE (ref) == ARRAY_REF)
-               newref = build4 (ARRAY_REF, TREE_TYPE (ref),
-                                unshare_expr (TREE_OPERAND (ref, 0)),
-                                running_off,
-                                NULL_TREE, NULL_TREE);
+               {
+                 newref = build4 (ARRAY_REF, TREE_TYPE (ref),
+                                  unshare_expr (TREE_OPERAND (ref, 0)),
+                                  running_off,
+                                  NULL_TREE, NULL_TREE);
+                 if (!useless_type_conversion_p (TREE_TYPE (vectype),
+                                                 TREE_TYPE (newref)))
+                   newref = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (vectype),
+                                    newref);
+               }
              else
-               newref = build2 (MEM_REF, TREE_TYPE (ref),
+               newref = build2 (MEM_REF, TREE_TYPE (vectype),
                                 running_off,
                                 TREE_OPERAND (ref, 1));