re PR tree-optimization/88934 (ICE: verify_gimple failed (Error: mismatching comparis...
authorRichard Biener <rguenther@suse.de>
Mon, 21 Jan 2019 14:49:42 +0000 (14:49 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 Jan 2019 14:49:42 +0000 (14:49 +0000)
2019-01-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/88934
* tree-vect-slp.c (vect_mask_constant_operand_p): Always look
at the possibly non-constant operand.
(vect_get_constant_vectors): Adjust.

* gfortran.dg/pr88934.f90: New testcase.

From-SVN: r268115

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

index 6fbfef4854b3f0d694866542b26ab00d566b64bd..f785a4a9d179b2e6f29f282f02cfa3e933462d9e 100644 (file)
@@ -1,3 +1,10 @@
+2019-01-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88934
+       * tree-vect-slp.c (vect_mask_constant_operand_p): Always look
+       at the possibly non-constant operand.
+       (vect_get_constant_vectors): Adjust.
+
 2019-01-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/71659
index a629dcdd84b771d02d3116311e389ddaed898808..3518747ee7b41612c2ef2a92d4c2ad53003abdc7 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/88934
+       * gfortran.dg/pr88934.f90: New testcase.
+
 2019-01-20  Ulrich Drepper  <drepper@redhat.com>
 
        Fix after C++ P0600 implementation.
diff --git a/gcc/testsuite/gfortran.dg/pr88934.f90 b/gcc/testsuite/gfortran.dg/pr88934.f90
new file mode 100644 (file)
index 0000000..7c76911
--- /dev/null
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! { dg-options "-O -ftree-vectorize" }
+! { dg-additional-options "-mvsx" { target powerpc*-*-* } }
+integer, parameter :: a=3
+  integer , dimension(a,a) :: b
+  logical, dimension(a,a) :: c
+  do i=0,1
+     b = ltoi(c)
+     do j=0,if
+        if (anymatmul(b) /= 0) then
+        end if
+     end do
+  end do
+contains
+  elemental function ltoi(d)
+    logical, intent(in) :: d
+    if (d) then
+       ltoi = 1
+    else
+       ltoi = 0
+    end if
+  end
+end
index 0e15087df98eac4d297c422ed0d5d59dbe50c347..40db1a208f114c22964dfb4ebfd27c03cecfbcaa 100644 (file)
@@ -3109,25 +3109,21 @@ vect_slp_bb (basic_block bb)
 }
 
 
-/* Return 1 if vector type of boolean constant which is OPNUM
-   operand in statement STMT_VINFO is a boolean vector.  */
+/* Return 1 if vector type STMT_VINFO is a boolean vector.  */
 
 static bool
-vect_mask_constant_operand_p (stmt_vec_info stmt_vinfo, int opnum)
+vect_mask_constant_operand_p (stmt_vec_info stmt_vinfo)
 {
   enum tree_code code = gimple_expr_code (stmt_vinfo->stmt);
   tree op, vectype;
   enum vect_def_type dt;
 
   /* For comparison and COND_EXPR type is chosen depending
-     on the other comparison operand.  */
+     on the non-constant other comparison operand.  */
   if (TREE_CODE_CLASS (code) == tcc_comparison)
     {
       gassign *stmt = as_a <gassign *> (stmt_vinfo->stmt);
-      if (opnum)
-       op = gimple_assign_rhs1 (stmt);
-      else
-       op = gimple_assign_rhs2 (stmt);
+      op = gimple_assign_rhs1 (stmt);
 
       if (!vect_is_simple_use (op, stmt_vinfo->vinfo, &dt, &vectype))
        gcc_unreachable ();
@@ -3142,8 +3138,6 @@ vect_mask_constant_operand_p (stmt_vec_info stmt_vinfo, int opnum)
 
       if (TREE_CODE (cond) == SSA_NAME)
        op = cond;
-      else if (opnum)
-       op = TREE_OPERAND (cond, 1);
       else
        op = TREE_OPERAND (cond, 0);
 
@@ -3302,7 +3296,7 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
 
   /* Check if vector type is a boolean vector.  */
   if (VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (op))
-      && vect_mask_constant_operand_p (stmt_vinfo, op_num))
+      && vect_mask_constant_operand_p (stmt_vinfo))
     vector_type
       = build_same_sized_truth_vector_type (STMT_VINFO_VECTYPE (stmt_vinfo));
   else