tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle even zero DR_OFFSET...
authorJakub Jelinek <jakub@redhat.com>
Fri, 21 Jun 2019 21:38:35 +0000 (23:38 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 21 Jun 2019 21:38:35 +0000 (23:38 +0200)
* tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle
even zero DR_OFFSET, but DR_BASE_ADDRESS of POINTER_PLUS_EXPR
containing the offset as possible simd lane access.  Look through
widening conversion.  Move the
TREE_CODE (DR_INIT (newdr)) == INTEGER_CST test earlier and reindent.

* g++.dg/vect/simd-2.cc: Don't xfail, instead expect vectorization on
x86.
* g++.dg/vect/simd-5.cc: Likewise.

From-SVN: r272575

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/vect/simd-2.cc
gcc/testsuite/g++.dg/vect/simd-5.cc
gcc/tree-vect-data-refs.c

index 06abb6b..5cab328 100644 (file)
@@ -1,3 +1,11 @@
+2019-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle
+       even zero DR_OFFSET, but DR_BASE_ADDRESS of POINTER_PLUS_EXPR
+       containing the offset as possible simd lane access.  Look through
+       widening conversion.  Move the
+       TREE_CODE (DR_INIT (newdr)) == INTEGER_CST test earlier and reindent.
+
 2019-06-21  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/90930
index 14ef07c..5e94d9a 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+       * g++.dg/vect/simd-2.cc: Don't xfail, instead expect vectorization on
+       x86.
+       * g++.dg/vect/simd-5.cc: Likewise.
+
 2019-06-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/90909
index 3160495..6f5737b 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-require-effective-target size32plus }
 // { dg-additional-options "-fopenmp-simd" }
 // { dg-additional-options "-mavx" { target avx_runtime } }
-// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { xfail *-*-* } } }
+// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } }
 
 #include "../../gcc.dg/vect/tree-vect.h"
 
index e975595..dd817b8 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-require-effective-target size32plus }
 // { dg-additional-options "-fopenmp-simd" }
 // { dg-additional-options "-mavx" { target avx_runtime } }
-// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { xfail *-*-* } } }
+// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } }
 
 #include "../../gcc.dg/vect/tree-vect.h"
 
index 1a72cff..20c8815 100644 (file)
@@ -4072,10 +4072,18 @@ vect_find_stmt_data_reference (loop_p loop, gimple *stmt,
          && DR_OFFSET (newdr)
          && DR_INIT (newdr)
          && DR_STEP (newdr)
+         && TREE_CODE (DR_INIT (newdr)) == INTEGER_CST
          && integer_zerop (DR_STEP (newdr)))
        {
+         tree base_address = DR_BASE_ADDRESS (newdr);
          tree off = DR_OFFSET (newdr);
          tree step = ssize_int (1);
+         if (integer_zerop (off)
+             && TREE_CODE (base_address) == POINTER_PLUS_EXPR)
+           {
+             off = TREE_OPERAND (base_address, 1);
+             base_address = TREE_OPERAND (base_address, 0);
+           }
          STRIP_NOPS (off);
          if (TREE_CODE (off) == MULT_EXPR
              && tree_fits_uhwi_p (TREE_OPERAND (off, 1)))
@@ -4084,39 +4092,47 @@ vect_find_stmt_data_reference (loop_p loop, gimple *stmt,
              off = TREE_OPERAND (off, 0);
              STRIP_NOPS (off);
            }
-         if (TREE_CODE (DR_INIT (newdr)) == INTEGER_CST)
+         if (CONVERT_EXPR_P (off)
+             && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (off, 0)))
+                 < TYPE_PRECISION (TREE_TYPE (off))))
+           off = TREE_OPERAND (off, 0);
+         if (TREE_CODE (off) == SSA_NAME)
            {
-             if (CONVERT_EXPR_P (off)
-                 && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (off, 0)))
-                     < TYPE_PRECISION (TREE_TYPE (off))))
-               off = TREE_OPERAND (off, 0);
-             if (TREE_CODE (off) == SSA_NAME)
+             gimple *def = SSA_NAME_DEF_STMT (off);
+             /* Look through widening conversion.  */
+             if (is_gimple_assign (def)
+                 && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def)))
+               {
+                 tree rhs1 = gimple_assign_rhs1 (def);
+                 if (TREE_CODE (rhs1) == SSA_NAME
+                     && INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
+                     && (TYPE_PRECISION (TREE_TYPE (off))
+                         > TYPE_PRECISION (TREE_TYPE (rhs1))))
+                   def = SSA_NAME_DEF_STMT (rhs1);
+               }
+             if (is_gimple_call (def)
+                 && gimple_call_internal_p (def)
+                 && (gimple_call_internal_fn (def) == IFN_GOMP_SIMD_LANE))
                {
-                 gimple *def = SSA_NAME_DEF_STMT (off);
+                 tree arg = gimple_call_arg (def, 0);
                  tree reft = TREE_TYPE (DR_REF (newdr));
-                 if (is_gimple_call (def)
-                     && gimple_call_internal_p (def)
-                     && (gimple_call_internal_fn (def) == IFN_GOMP_SIMD_LANE))
+                 gcc_assert (TREE_CODE (arg) == SSA_NAME);
+                 arg = SSA_NAME_VAR (arg);
+                 if (arg == loop->simduid
+                     /* For now.  */
+                     && tree_int_cst_equal (TYPE_SIZE_UNIT (reft), step))
                    {
-                     tree arg = gimple_call_arg (def, 0);
-                     gcc_assert (TREE_CODE (arg) == SSA_NAME);
-                     arg = SSA_NAME_VAR (arg);
-                     if (arg == loop->simduid
-                         /* For now.  */
-                         && tree_int_cst_equal (TYPE_SIZE_UNIT (reft), step))
-                       {
-                         DR_OFFSET (newdr) = ssize_int (0);
-                         DR_STEP (newdr) = step;
-                         DR_OFFSET_ALIGNMENT (newdr) = BIGGEST_ALIGNMENT;
-                         DR_STEP_ALIGNMENT (newdr)
-                           = highest_pow2_factor (step);
-                         /* Mark as simd-lane access.  */
-                         tree arg2 = gimple_call_arg (def, 1);
-                         newdr->aux = (void *) (-1 - tree_to_uhwi (arg2));
-                         free_data_ref (dr);
-                         datarefs->safe_push (newdr);
-                         return opt_result::success ();
-                       }
+                     DR_BASE_ADDRESS (newdr) = base_address;
+                     DR_OFFSET (newdr) = ssize_int (0);
+                     DR_STEP (newdr) = step;
+                     DR_OFFSET_ALIGNMENT (newdr) = BIGGEST_ALIGNMENT;
+                     DR_STEP_ALIGNMENT (newdr) = highest_pow2_factor (step);
+                     /* Mark as simd-lane access.  */
+                     tree arg2 = gimple_call_arg (def, 1);
+                     newdr->aux = (void *) (-1 - tree_to_uhwi (arg2));
+                     free_data_ref (dr);
+                     datarefs->safe_push (newdr);
+                     return opt_result::success ();
                    }
                }
            }