]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix mask type choice in vectorizable_call (PR 89535)
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Mar 2019 13:05:40 +0000 (13:05 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Mar 2019 13:05:40 +0000 (13:05 +0000)
This is another case in which we were failing to pass the expected
mask vector type to vect_get_vec_def_for_operand.

2019-02-28  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR tree-optimization/89535
* tree-vect-stmts.c (vectorizable_call): Record the vector types
for each operand.  Calculate the fallback choice for mask operands
and pass it to vect_get_vec_def_for_operand.

gcc/testsuite/
PR tree-optimization/89535
* gfortran.dg/vect/pr89535.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269308 138bc75d-0d04-0410-961f-82ee72b054a4

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

index be1cbe574446955f6e458a3eaf2f7eded1f0a678..4516510751df27ed7824059b6aacd6166e13609d 100644 (file)
@@ -1,3 +1,10 @@
+2019-03-01  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/89535
+       * tree-vect-stmts.c (vectorizable_call): Record the vector types
+       for each operand.  Calculate the fallback choice for mask operands
+       and pass it to vect_get_vec_def_for_operand.
+
 2019-03-01  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/89541
index f6a8e6a44383955df2a5da71a69e48302bbb03c7..2ad0d80f04a64c44cec972b8414225f05b039052 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-01  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/89535
+       * gfortran.dg/vect/pr89535.f90: New test.
+
 2019-03-01  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/89541
diff --git a/gcc/testsuite/gfortran.dg/vect/pr89535.f90 b/gcc/testsuite/gfortran.dg/vect/pr89535.f90
new file mode 100644 (file)
index 0000000..3e2e997
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile }
+
+subroutine foo(tmp1, tmp2, tmp3)
+  integer, parameter :: n = 100
+  real :: tmp1(n,2), tmp2(n), tmp3(n)
+  integer :: i, c1, c2, c3
+  logical :: cond
+  common c1, c2, c3
+
+  c2 = c3
+  cond = c1 .eq. 1 .and. c3 .eq. 1
+  do i = 1,100
+     if (cond) tmp2(i) = tmp1(i,1) / tmp1(i,2)
+  end do
+  do i = 1,100
+     if (cond) tmp3(i) = tmp2(i)
+  end do
+end subroutine foo
index 4359fc9978ae9a0109679792f760c5af0aebcae1..6c631db90399264945bb4d2cabb269976becc45e 100644 (file)
@@ -3123,6 +3123,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
   enum vect_def_type dt[4]
     = { vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type,
        vect_unknown_def_type };
+  tree vectypes[ARRAY_SIZE (dt)] = {};
   int ndts = ARRAY_SIZE (dt);
   int ncopies, j;
   auto_vec<tree, 8> vargs;
@@ -3182,10 +3183,8 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
 
   for (i = 0; i < nargs; i++)
     {
-      tree opvectype;
-
       op = gimple_call_arg (stmt, i);
-      if (!vect_is_simple_use (op, vinfo, &dt[i], &opvectype))
+      if (!vect_is_simple_use (op, vinfo, &dt[i], &vectypes[i]))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -3211,9 +3210,9 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
        rhs_type = TREE_TYPE (op);
 
       if (!vectype_in)
-       vectype_in = opvectype;
-      else if (opvectype
-              && opvectype != vectype_in)
+       vectype_in = vectypes[i];
+      else if (vectypes[i]
+              && vectypes[i] != vectype_in)
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -3446,12 +3445,19 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
              continue;
            }
 
+         if (mask_opno >= 0 && !vectypes[mask_opno])
+           {
+             gcc_assert (modifier != WIDEN);
+             vectypes[mask_opno]
+               = build_same_sized_truth_vector_type (vectype_in);
+           }
+
          for (i = 0; i < nargs; i++)
            {
              op = gimple_call_arg (stmt, i);
              if (j == 0)
                vec_oprnd0
-                 = vect_get_vec_def_for_operand (op, stmt_info);
+                 = vect_get_vec_def_for_operand (op, stmt_info, vectypes[i]);
              else
                vec_oprnd0
                  = vect_get_vec_def_for_stmt_copy (vinfo, orig_vargs[i]);
@@ -3584,7 +3590,8 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
              if (j == 0)
                {
                  vec_oprnd0
-                   = vect_get_vec_def_for_operand (op, stmt_info);
+                   = vect_get_vec_def_for_operand (op, stmt_info,
+                                                   vectypes[i]);
                  vec_oprnd1
                    = vect_get_vec_def_for_stmt_copy (vinfo, vec_oprnd0);
                }