tree-vect-stmts.c (scan_operand_equal_p): Look through MEM_REF with SSA_NAME address...
authorJakub Jelinek <jakub@redhat.com>
Mon, 8 Jul 2019 22:11:59 +0000 (00:11 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 8 Jul 2019 22:11:59 +0000 (00:11 +0200)
* tree-vect-stmts.c (scan_operand_equal_p): Look through MEM_REF
with SSA_NAME address of POINTER_PLUS_EXPR.  Handle MULT_EXPR
and casts in offset when different, both through gimple stmts
and through trees.  Rewritten using loops to minimize code duplication
for each operand.

* g++.dg/vect/simd-6.cc: Replace xfail with target x86.
* g++.dg/vect/simd-9.cc: Likewise.

* testsuite/libgomp.c++/scan-13.C: Replace xfail with target x86.
* testsuite/libgomp.c++/scan-16.C: Likewise.

From-SVN: r273249

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/vect/simd-6.cc
gcc/testsuite/g++.dg/vect/simd-9.cc
gcc/tree-vect-stmts.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c++/scan-13.C
libgomp/testsuite/libgomp.c++/scan-16.C

index d0d34948d1ba4b34f7c321ba6690278133c17d98..543337667dd302c323669f8f7cba22b4f9f95d3c 100644 (file)
@@ -1,3 +1,11 @@
+2019-07-08  Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-vect-stmts.c (scan_operand_equal_p): Look through MEM_REF
+       with SSA_NAME address of POINTER_PLUS_EXPR.  Handle MULT_EXPR
+       and casts in offset when different, both through gimple stmts
+       and through trees.  Rewritten using loops to minimize code duplication
+       for each operand.
+
 2019-07-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * emit-rtl.c (set_insn_locations): New function moved from...
index 3e24415db8540beb3b01fb9f722e57f6a5e94551..31ba4200c041c889361023ec26ba64934aa9b362 100644 (file)
@@ -1,5 +1,8 @@
 2019-07-08  Jakub Jelinek  <jakub@redhat.com>
 
+       * g++.dg/vect/simd-6.cc: Replace xfail with target x86.
+       * g++.dg/vect/simd-9.cc: Likewise.
+
        PR c++/91110
        * g++.dg/gomp/pr91110.C: New test.
 
index 997f7b1cf92a6c7ae9708c24411022e4302d9b14..883b769a9b854bd8c1915648d15ea8996d461f05 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 bfef445d1210bad33695e70c819e4410da6c0f7a..4c5b0508fbd79f0e6aa311072062725536d8e2a3 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 ead079dac45857d10ddfd130d376f264f64b3d2d..10ce2a22f85e96ff882e7b688366ec499ccb52fb 100644 (file)
@@ -6334,30 +6334,88 @@ get_group_alias_ptr_type (stmt_vec_info first_stmt_info)
 static bool
 scan_operand_equal_p (tree ref1, tree ref2)
 {
-  machine_mode mode1, mode2;
-  poly_int64 bitsize1, bitsize2, bitpos1, bitpos2;
-  tree offset1, offset2;
-  int unsignedp1, unsignedp2, reversep1, reversep2;
-  int volatilep1 = 0, volatilep2 = 0;
-  tree base1 = get_inner_reference (ref1, &bitsize1, &bitpos1, &offset1,
-                                   &mode1, &unsignedp1, &reversep1,
-                                   &volatilep1);
-  tree base2 = get_inner_reference (ref2, &bitsize2, &bitpos2, &offset2,
-                                   &mode2, &unsignedp2, &reversep2,
-                                   &volatilep2);
-  if (reversep1 || reversep2 || volatilep1 || volatilep2)
-    return false;
-  if (!operand_equal_p (base1, base2, 0))
-    return false;
-  if (maybe_ne (bitpos1, 0) || maybe_ne (bitpos2, 0))
-    return false;
-  if (maybe_ne (bitsize1, bitsize2))
+  tree ref[2] = { ref1, ref2 };
+  poly_int64 bitsize[2], bitpos[2];
+  tree offset[2], base[2];
+  for (int i = 0; i < 2; ++i)
+    {
+      machine_mode mode;
+      int unsignedp, reversep, volatilep = 0;
+      base[i] = get_inner_reference (ref[i], &bitsize[i], &bitpos[i],
+                                    &offset[i], &mode, &unsignedp,
+                                    &reversep, &volatilep);
+      if (reversep || volatilep || maybe_ne (bitpos[i], 0))
+       return false;
+      if (TREE_CODE (base[i]) == MEM_REF
+         && offset[i] == NULL_TREE
+         && TREE_CODE (TREE_OPERAND (base[i], 0)) == SSA_NAME)
+       {
+         gimple *def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (base[i], 0));
+         if (is_gimple_assign (def_stmt)
+             && gimple_assign_rhs_code (def_stmt) == POINTER_PLUS_EXPR
+             && TREE_CODE (gimple_assign_rhs1 (def_stmt)) == ADDR_EXPR
+             && TREE_CODE (gimple_assign_rhs2 (def_stmt)) == SSA_NAME)
+           {
+             if (maybe_ne (mem_ref_offset (base[i]), 0))
+               return false;
+             base[i] = TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0);
+             offset[i] = gimple_assign_rhs2 (def_stmt);
+           }
+       }
+    }
+
+  if (!operand_equal_p (base[0], base[1], 0))
     return false;
-  if (offset1 != offset2
-      && (!offset1
-         || !offset2
-         || !operand_equal_p (offset1, offset2, 0)))
+  if (maybe_ne (bitsize[0], bitsize[1]))
     return false;
+  if (offset[0] != offset[1])
+    {
+      if (!offset[0] || !offset[1])
+       return false;
+      if (!operand_equal_p (offset[0], offset[1], 0))
+       {
+         tree step[2];
+         for (int i = 0; i < 2; ++i)
+           {
+             step[i] = integer_one_node;
+             if (TREE_CODE (offset[i]) == SSA_NAME)
+               {
+                 gimple *def_stmt = SSA_NAME_DEF_STMT (offset[i]);
+                 if (is_gimple_assign (def_stmt)
+                     && gimple_assign_rhs_code (def_stmt) == MULT_EXPR
+                     && (TREE_CODE (gimple_assign_rhs2 (def_stmt))
+                         == INTEGER_CST))
+                   {
+                     step[i] = gimple_assign_rhs2 (def_stmt);
+                     offset[i] = gimple_assign_rhs1 (def_stmt);
+                   }
+               }
+             else if (TREE_CODE (offset[i]) == MULT_EXPR)
+               {
+                 step[i] = TREE_OPERAND (offset[i], 1);
+                 offset[i] = TREE_OPERAND (offset[i], 0);
+               }
+             tree rhs1 = NULL_TREE;
+             if (TREE_CODE (offset[i]) == SSA_NAME)
+               {
+                 gimple *def_stmt = SSA_NAME_DEF_STMT (offset[i]);
+                 if (gimple_assign_cast_p (def_stmt))
+                   rhs1 = gimple_assign_rhs1 (def_stmt);
+               }
+             else if (CONVERT_EXPR_P (offset[i]))
+               rhs1 = TREE_OPERAND (offset[i], 0);
+             if (rhs1
+                 && INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
+                 && INTEGRAL_TYPE_P (TREE_TYPE (offset[i]))
+                 && (TYPE_PRECISION (TREE_TYPE (offset[i]))
+                     >= TYPE_PRECISION (TREE_TYPE (rhs1))))
+               offset[i] = rhs1;
+           }
+         if (!operand_equal_p (offset[0], offset[1], 0)
+             || !operand_equal_p (step[0], step[1], 0))
+           return false;
+       }
+    }
   return true;
 }
 
index 107c5c9d06f95922249dd648bf47438fda8237e2..53125a5ac379cc84c34744dbb7704211455306a4 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-08  Jakub Jelinek  <jakub@redhat.com>
+
+       * testsuite/libgomp.c++/scan-13.C: Replace xfail with target x86.
+       * testsuite/libgomp.c++/scan-16.C: Likewise.
+
 2019-07-06  Jakub Jelinek  <jakub@redhat.com>
 
        * testsuite/libgomp.c/scan-19.c: New test.
index eb91297a82769c5b2b2db39b643f817806468b34..9d0062556d39f8f755856bbc7c13280bc0b6da73 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-require-effective-target size32plus }
 // { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" }
 // { dg-additional-options "-mavx" { target avx_runtime } }
-// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { xfail *-*-* } } }
+// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } }
 
 extern "C" void abort ();
 
index 025860e8c7af9fbd16f0f1edf980f8996f8ed11a..108660bfbe964fefcaf586b69a8a56b665e5e871 100644 (file)
@@ -1,7 +1,7 @@
 // { dg-require-effective-target size32plus }
 // { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" }
 // { dg-additional-options "-mavx" { target avx_runtime } }
-// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { xfail *-*-* } } }
+// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } }
 
 extern "C" void abort ();