[9a/n] PR85694: Reorder vect_is_simple_use arguments
authorRichard Sandiford <richard.sandiford@arm.com>
Sat, 30 Jun 2018 12:46:36 +0000 (12:46 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 30 Jun 2018 12:46:36 +0000 (12:46 +0000)
As suggested by Richard B., this patch reorders the arguments to
vect_is_simple_use so that def_stmt comes last and is optional.
Many callers can then drop it, making it more obvious which of
the remaining calls would be affected by the next patch.

2018-06-30  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* tree-vectorizer.h (vect_is_simple_use): Move the gimple ** to the
end and default to null.
* tree-vect-loop.c (vect_create_epilog_for_reduction)
(vectorizable_reduction): Update calls accordingly, dropping the
gimple ** argument if the passed-back statement isn't needed.
* tree-vect-patterns.c (vect_get_internal_def, type_conversion_p)
(vect_recog_rotate_pattern): Likewise.
(vect_recog_mask_conversion_pattern): Likewise.
* tree-vect-slp.c (vect_get_and_check_slp_defs): Likewise.
(vect_mask_constant_operand_p): Likewise.
* tree-vect-stmts.c (is_simple_and_all_uses_invariant, process_use):
(vect_model_simple_cost, vect_get_vec_def_for_operand): Likewise.
(get_group_load_store_type, get_load_store_type): Likewise.
(vect_check_load_store_mask, vect_check_store_rhs): Likewise.
(vectorizable_call, vectorizable_simd_clone_call): Likewise.
(vectorizable_conversion, vectorizable_assignment): Likewise.
(vectorizable_shift, vectorizable_operation): Likewise.
(vectorizable_store, vect_is_simple_cond): Likewise.
(vectorizable_condition, vectorizable_comparison): Likewise.
(get_same_sized_vectype, vect_get_mask_type_for_stmt): Likewise.
(vect_is_simple_use): Rename the def_stmt argument to def_stmt_out
and move it to the end.  Cope with null def_stmt_outs.

From-SVN: r262272

gcc/ChangeLog
gcc/tree-vect-loop.c
gcc/tree-vect-patterns.c
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.h

index 3854308a7b95c98acd80b464b1f5fa2a142dd2e0..528bc4bde5c8b749990fc8e0d3ffc759ebdb6c30 100644 (file)
@@ -1,3 +1,28 @@
+2018-06-30  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * tree-vectorizer.h (vect_is_simple_use): Move the gimple ** to the
+       end and default to null.
+       * tree-vect-loop.c (vect_create_epilog_for_reduction)
+       (vectorizable_reduction): Update calls accordingly, dropping the
+       gimple ** argument if the passed-back statement isn't needed.
+       * tree-vect-patterns.c (vect_get_internal_def, type_conversion_p)
+       (vect_recog_rotate_pattern): Likewise.
+       (vect_recog_mask_conversion_pattern): Likewise.
+       * tree-vect-slp.c (vect_get_and_check_slp_defs): Likewise.
+       (vect_mask_constant_operand_p): Likewise.
+       * tree-vect-stmts.c (is_simple_and_all_uses_invariant, process_use):
+       (vect_model_simple_cost, vect_get_vec_def_for_operand): Likewise.
+       (get_group_load_store_type, get_load_store_type): Likewise.
+       (vect_check_load_store_mask, vect_check_store_rhs): Likewise.
+       (vectorizable_call, vectorizable_simd_clone_call): Likewise.
+       (vectorizable_conversion, vectorizable_assignment): Likewise.
+       (vectorizable_shift, vectorizable_operation): Likewise.
+       (vectorizable_store, vect_is_simple_cond): Likewise.
+       (vectorizable_condition, vectorizable_comparison): Likewise.
+       (get_same_sized_vectype, vect_get_mask_type_for_stmt): Likewise.
+       (vect_is_simple_use): Rename the def_stmt argument to def_stmt_out
+       and move it to the end.  Cope with null def_stmt_outs.
+
 2018-06-30  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * Makefile.in (FLAGS_TO_PASS): Add RANLIB_FOR_TARGET.
index 8741e0bc02a9d4771b423292df01ca8c0dd7c845..73a1a8f027c2ec2bbcdc919d86a34bb23e62ee8a 100644 (file)
@@ -4572,7 +4572,6 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
     {
       /* Get at the scalar def before the loop, that defines the initial value
         of the reduction variable.  */
-      gimple *def_stmt;
       initial_def = PHI_ARG_DEF_FROM_EDGE (reduc_def_stmt,
                                           loop_preheader_edge (loop));
       /* Optimize: if initial_def is for REDUC_MAX smaller than the base
@@ -4587,7 +4586,7 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
              || (induc_code == MIN_EXPR
                  && tree_int_cst_lt (induc_val, initial_def))))
        induc_val = initial_def;
-      vect_is_simple_use (initial_def, loop_vinfo, &def_stmt, &initial_def_dt);
+      vect_is_simple_use (initial_def, loop_vinfo, &initial_def_dt);
       vec_initial_def = get_initial_def_for_reduction (stmt, initial_def,
                                                       &adjustment_def);
       vec_initial_defs.create (1);
@@ -6396,7 +6395,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
         continue;
 
       is_simple_use = vect_is_simple_use (ops[i], loop_vinfo,
-                                         &def_stmt, &dts[i], &tem);
+                                         &dts[i], &tem, &def_stmt);
       dt = dts[i];
       gcc_assert (is_simple_use);
       if (dt == vect_reduction_def)
@@ -6592,8 +6591,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
            = PHI_ARG_DEF_FROM_EDGE (def_stmt, loop_preheader_edge (loop));
 
          gcc_assert (cond_reduc_val != NULL_TREE);
-         vect_is_simple_use (cond_initial_val, loop_vinfo,
-                             &def_stmt, &cond_initial_dt);
+         vect_is_simple_use (cond_initial_val, loop_vinfo, &cond_initial_dt);
          if (cond_initial_dt == vect_constant_def
              && types_compatible_p (TREE_TYPE (cond_initial_val),
                                     TREE_TYPE (cond_reduc_val)))
index 9654bd7818a08f2f9f3ec3e430f102178f921359..6fb07fd1265784f71869e22c29ada73c8261baad 100644 (file)
@@ -160,7 +160,7 @@ vect_get_internal_def (vec_info *vinfo, tree op)
   vect_def_type dt;
   gimple *def_stmt;
   if (TREE_CODE (op) != SSA_NAME
-      || !vect_is_simple_use (op, vinfo, &def_stmt, &dt)
+      || !vect_is_simple_use (op, vinfo, &dt, &def_stmt)
       || dt != vect_internal_def)
     return NULL;
 
@@ -177,14 +177,13 @@ static bool
 type_conversion_p (tree name, gimple *use_stmt, bool check_sign,
                   tree *orig_type, gimple **def_stmt, bool *promotion)
 {
-  gimple *dummy_gimple;
   stmt_vec_info stmt_vinfo;
   tree type = TREE_TYPE (name);
   tree oprnd0;
   enum vect_def_type dt;
 
   stmt_vinfo = vinfo_for_stmt (use_stmt);
-  if (!vect_is_simple_use (name, stmt_vinfo->vinfo, def_stmt, &dt))
+  if (!vect_is_simple_use (name, stmt_vinfo->vinfo, &dt, def_stmt))
     return false;
 
   if (dt != vect_internal_def
@@ -219,7 +218,7 @@ type_conversion_p (tree name, gimple *use_stmt, bool check_sign,
   else
     *promotion = false;
 
-  if (!vect_is_simple_use (oprnd0, stmt_vinfo->vinfo, &dummy_gimple, &dt))
+  if (!vect_is_simple_use (oprnd0, stmt_vinfo->vinfo, &dt))
     return false;
 
   return true;
@@ -1795,7 +1794,7 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_out)
       || !TYPE_UNSIGNED (type))
     return NULL;
 
-  if (!vect_is_simple_use (oprnd1, vinfo, &def_stmt, &dt))
+  if (!vect_is_simple_use (oprnd1, vinfo, &dt, &def_stmt))
     return NULL;
 
   if (dt != vect_internal_def
@@ -3930,13 +3929,10 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_out)
          && known_le (TYPE_VECTOR_SUBPARTS (vectype1),
                       TYPE_VECTOR_SUBPARTS (vectype2)))
        {
-         gimple *dummy;
          enum vect_def_type dt;
-         if (vect_is_simple_use (TREE_OPERAND (rhs1, 0), stmt_vinfo->vinfo,
-                                 &dummy, &dt)
+         if (vect_is_simple_use (TREE_OPERAND (rhs1, 0), vinfo, &dt)
              && dt == vect_external_def
-             && vect_is_simple_use (TREE_OPERAND (rhs1, 1), stmt_vinfo->vinfo,
-                                    &dummy, &dt)
+             && vect_is_simple_use (TREE_OPERAND (rhs1, 1), vinfo, &dt)
              && (dt == vect_external_def
                  || dt == vect_constant_def))
            {
index 31b58dbb090caff51631c1ca668ee87051822326..573ed76f6546f1ff1b066e73e4ead4ad1e377118 100644 (file)
@@ -348,7 +348,7 @@ again:
 
       oprnd_info = (*oprnds_info)[i];
 
-      if (!vect_is_simple_use (oprnd, vinfo, &def_stmt, &dt))
+      if (!vect_is_simple_use (oprnd, vinfo, &dt, &def_stmt))
        {
          if (dump_enabled_p ())
            {
@@ -3105,7 +3105,6 @@ vect_mask_constant_operand_p (gimple *stmt, int opnum)
   stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
   enum tree_code code = gimple_expr_code (stmt);
   tree op, vectype;
-  gimple *def_stmt;
   enum vect_def_type dt;
 
   /* For comparison and COND_EXPR type is chosen depending
@@ -3117,8 +3116,7 @@ vect_mask_constant_operand_p (gimple *stmt, int opnum)
       else
        op = gimple_assign_rhs2 (stmt);
 
-      if (!vect_is_simple_use (op, stmt_vinfo->vinfo, &def_stmt,
-                              &dt, &vectype))
+      if (!vect_is_simple_use (op, stmt_vinfo->vinfo, &dt, &vectype))
        gcc_unreachable ();
 
       return !vectype || VECTOR_BOOLEAN_TYPE_P (vectype);
@@ -3135,8 +3133,7 @@ vect_mask_constant_operand_p (gimple *stmt, int opnum)
       else
        op = TREE_OPERAND (cond, 0);
 
-      if (!vect_is_simple_use (op, stmt_vinfo->vinfo, &def_stmt,
-                              &dt, &vectype))
+      if (!vect_is_simple_use (op, stmt_vinfo->vinfo, &dt, &vectype))
        gcc_unreachable ();
 
       return !vectype || VECTOR_BOOLEAN_TYPE_P (vectype);
index 07dc222b0dcedc2c5a33f072470a802d51139d0b..c1c5410d46bb55d847cea1a60334794c150b2f2b 100644 (file)
@@ -260,7 +260,6 @@ bool
 is_simple_and_all_uses_invariant (gimple *stmt, loop_vec_info loop_vinfo)
 {
   tree op;
-  gimple *def_stmt;
   ssa_op_iter iter;
 
   if (!is_gimple_assign (stmt))
@@ -270,7 +269,7 @@ is_simple_and_all_uses_invariant (gimple *stmt, loop_vec_info loop_vinfo)
     {
       enum vect_def_type dt = vect_uninitialized_def;
 
-      if (!vect_is_simple_use (op, loop_vinfo, &def_stmt, &dt))
+      if (!vect_is_simple_use (op, loop_vinfo, &dt))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -472,7 +471,7 @@ process_use (gimple *stmt, tree use, loop_vec_info loop_vinfo,
   if (!force && !exist_non_indexing_operands_for_use_p (use, stmt))
      return true;
 
-  if (!vect_is_simple_use (use, loop_vinfo, &def_stmt, &dt))
+  if (!vect_is_simple_use (use, loop_vinfo, &dt, &def_stmt))
     {
       if (dump_enabled_p ())
         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -908,11 +907,10 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies,
       for (unsigned i = 0; i < gimple_num_ops (stmt); ++i)
        {
          tree op = gimple_op (stmt, i);
-         gimple *def_stmt;
          enum vect_def_type dt;
          if (!op || op == lhs)
            continue;
-         if (vect_is_simple_use (op, stmt_info->vinfo, &def_stmt, &dt)
+         if (vect_is_simple_use (op, stmt_info->vinfo, &dt)
              && (dt == vect_constant_def || dt == vect_external_def))
            prologue_cost += vect_prologue_cost_for_slp_op (node, stmt_info,
                                                            i, dt, cost_vec);
@@ -1567,7 +1565,7 @@ vect_get_vec_def_for_operand (tree op, gimple *stmt, tree vectype)
       dump_printf (MSG_NOTE, "\n");
     }
 
-  is_simple_use = vect_is_simple_use (op, loop_vinfo, &def_stmt, &dt);
+  is_simple_use = vect_is_simple_use (op, loop_vinfo, &dt, &def_stmt);
   gcc_assert (is_simple_use);
   if (def_stmt && dump_enabled_p ())
     {
@@ -2336,9 +2334,8 @@ get_group_load_store_type (gimple *stmt, tree vectype, bool slp,
       while (next_stmt)
        {
          tree op = vect_get_store_rhs (next_stmt);
-         gimple *def_stmt;
          enum vect_def_type dt;
-         if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt))
+         if (!vect_is_simple_use (op, vinfo, &dt))
            {
              if (dump_enabled_p ())
                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -2436,10 +2433,9 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp, bool masked_p,
   if (STMT_VINFO_GATHER_SCATTER_P (stmt_info))
     {
       *memory_access_type = VMAT_GATHER_SCATTER;
-      gimple *def_stmt;
       if (!vect_check_gather_scatter (stmt, loop_vinfo, gs_info))
        gcc_unreachable ();
-      else if (!vect_is_simple_use (gs_info->offset, vinfo, &def_stmt,
+      else if (!vect_is_simple_use (gs_info->offset, vinfo,
                                    &gs_info->offset_dt,
                                    &gs_info->offset_vectype))
        {
@@ -2536,11 +2532,9 @@ vect_check_load_store_mask (gimple *stmt, tree mask,
     }
 
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
-  gimple *def_stmt;
   enum vect_def_type mask_dt;
   tree mask_vectype;
-  if (!vect_is_simple_use (mask, stmt_info->vinfo, &def_stmt, &mask_dt,
-                          &mask_vectype))
+  if (!vect_is_simple_use (mask, stmt_info->vinfo, &mask_dt, &mask_vectype))
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -2601,11 +2595,9 @@ vect_check_store_rhs (gimple *stmt, tree rhs, vect_def_type *rhs_dt_out,
     }
 
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
-  gimple *def_stmt;
   enum vect_def_type rhs_dt;
   tree rhs_vectype;
-  if (!vect_is_simple_use (rhs, stmt_info->vinfo, &def_stmt, &rhs_dt,
-                          &rhs_vectype))
+  if (!vect_is_simple_use (rhs, stmt_info->vinfo, &rhs_dt, &rhs_vectype))
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -3136,7 +3128,6 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
   vec_info *vinfo = stmt_info->vinfo;
   tree fndecl, new_temp, rhs_type;
-  gimple *def_stmt;
   enum vect_def_type dt[3]
     = {vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type};
   int ndts = 3;
@@ -3210,7 +3201,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       if (!rhs_type)
        rhs_type = TREE_TYPE (op);
 
-      if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt[i], &opvectype))
+      if (!vect_is_simple_use (op, vinfo, &dt[i], &opvectype))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -3731,7 +3722,6 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
   vec_info *vinfo = stmt_info->vinfo;
   struct loop *loop = loop_vinfo ? LOOP_VINFO_LOOP (loop_vinfo) : NULL;
   tree fndecl, new_temp;
-  gimple *def_stmt;
   gimple *new_stmt = NULL;
   int ncopies, j;
   auto_vec<simd_call_arg_info> arginfo;
@@ -3794,7 +3784,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
       thisarginfo.simd_lane_linear = false;
 
       op = gimple_call_arg (stmt, i);
-      if (!vect_is_simple_use (op, vinfo, &def_stmt, &thisarginfo.dt,
+      if (!vect_is_simple_use (op, vinfo, &thisarginfo.dt,
                               &thisarginfo.vectype)
          || thisarginfo.dt == vect_uninitialized_def)
        {
@@ -4575,7 +4565,6 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
   enum tree_code codecvt1 = ERROR_MARK, codecvt2 = ERROR_MARK;
   tree decl1 = NULL_TREE, decl2 = NULL_TREE;
   tree new_temp;
-  gimple *def_stmt;
   enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type};
   int ndts = 2;
   gimple *new_stmt = NULL;
@@ -4651,7 +4640,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
     }
 
   /* Check the operands of the operation.  */
-  if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype_in))
+  if (!vect_is_simple_use (op0, vinfo, &dt[0], &vectype_in))
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -4667,9 +4656,9 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi,
       /* For WIDEN_MULT_EXPR, if OP0 is a constant, use the type of
         OP1.  */
       if (CONSTANT_CLASS_P (op0))
-       ok = vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1], &vectype_in);
+       ok = vect_is_simple_use (op1, vinfo, &dt[1], &vectype_in);
       else
-       ok = vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1]);
+       ok = vect_is_simple_use (op1, vinfo, &dt[1]);
 
       if (!ok)
        {
@@ -5171,7 +5160,6 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
   tree new_temp;
-  gimple *def_stmt;
   enum vect_def_type dt[1] = {vect_unknown_def_type};
   int ndts = 1;
   int ncopies;
@@ -5224,7 +5212,7 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
 
   gcc_assert (ncopies >= 1);
 
-  if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt[0], &vectype_in))
+  if (!vect_is_simple_use (op, vinfo, &dt[0], &vectype_in))
     {
       if (dump_enabled_p ())
         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5380,7 +5368,6 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
   optab optab;
   int icode;
   machine_mode optab_op2_mode;
-  gimple *def_stmt;
   enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type};
   int ndts = 2;
   gimple *new_stmt = NULL;
@@ -5430,7 +5417,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
     }
 
   op0 = gimple_assign_rhs1 (stmt);
-  if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype))
+  if (!vect_is_simple_use (op0, vinfo, &dt[0], &vectype))
     {
       if (dump_enabled_p ())
         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5457,7 +5444,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
     return false;
 
   op1 = gimple_assign_rhs2 (stmt);
-  if (!vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1], &op1_vectype))
+  if (!vect_is_simple_use (op1, vinfo, &dt[1], &op1_vectype))
     {
       if (dump_enabled_p ())
         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5746,7 +5733,6 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   int op_type;
   optab optab;
   bool target_support_p;
-  gimple *def_stmt;
   enum vect_def_type dt[3]
     = {vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type};
   int ndts = 3;
@@ -5817,7 +5803,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
     }
 
   op0 = gimple_assign_rhs1 (stmt);
-  if (!vect_is_simple_use (op0, vinfo, &def_stmt, &dt[0], &vectype))
+  if (!vect_is_simple_use (op0, vinfo, &dt[0], &vectype))
     {
       if (dump_enabled_p ())
         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5871,7 +5857,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   if (op_type == binary_op || op_type == ternary_op)
     {
       op1 = gimple_assign_rhs2 (stmt);
-      if (!vect_is_simple_use (op1, vinfo, &def_stmt, &dt[1]))
+      if (!vect_is_simple_use (op1, vinfo, &dt[1]))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -5882,7 +5868,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
   if (op_type == ternary_op)
     {
       op2 = gimple_assign_rhs3 (stmt);
-      if (!vect_is_simple_use (op2, vinfo, &def_stmt, &dt[2]))
+      if (!vect_is_simple_use (op2, vinfo, &dt[2]))
        {
          if (dump_enabled_p ())
            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@@ -6196,7 +6182,6 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
   machine_mode vec_mode;
   tree dummy;
   enum dr_alignment_support alignment_support_scheme;
-  gimple *def_stmt;
   enum vect_def_type rhs_dt = vect_unknown_def_type;
   enum vect_def_type mask_dt = vect_unknown_def_type;
   stmt_vec_info prev_stmt_info = NULL;
@@ -6757,7 +6742,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
                    vec_oprnd = vec_oprnds[j];
                  else
                    {
-                     vect_is_simple_use (op, vinfo, &def_stmt, &rhs_dt);
+                     vect_is_simple_use (op, vinfo, &rhs_dt);
                      vec_oprnd = vect_get_vec_def_for_stmt_copy (rhs_dt,
                                                                  vec_oprnd);
                    }
@@ -7003,7 +6988,7 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
          for (i = 0; i < group_size; i++)
            {
              op = oprnds[i];
-             vect_is_simple_use (op, vinfo, &def_stmt, &rhs_dt);
+             vect_is_simple_use (op, vinfo, &rhs_dt);
              vec_oprnd = vect_get_vec_def_for_stmt_copy (rhs_dt, op);
              dr_chain[i] = vec_oprnd;
              oprnds[i] = vec_oprnd;
@@ -8588,9 +8573,7 @@ vect_is_simple_cond (tree cond, vec_info *vinfo,
   if (TREE_CODE (cond) == SSA_NAME
       && VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (cond)))
     {
-      gimple *lhs_def_stmt = SSA_NAME_DEF_STMT (cond);
-      if (!vect_is_simple_use (cond, vinfo, &lhs_def_stmt,
-                              &dts[0], comp_vectype)
+      if (!vect_is_simple_use (cond, vinfo, &dts[0], comp_vectype)
          || !*comp_vectype
          || !VECTOR_BOOLEAN_TYPE_P (*comp_vectype))
        return false;
@@ -8605,8 +8588,7 @@ vect_is_simple_cond (tree cond, vec_info *vinfo,
 
   if (TREE_CODE (lhs) == SSA_NAME)
     {
-      gimple *lhs_def_stmt = SSA_NAME_DEF_STMT (lhs);
-      if (!vect_is_simple_use (lhs, vinfo, &lhs_def_stmt, &dts[0], &vectype1))
+      if (!vect_is_simple_use (lhs, vinfo, &dts[0], &vectype1))
        return false;
     }
   else if (TREE_CODE (lhs) == INTEGER_CST || TREE_CODE (lhs) == REAL_CST
@@ -8617,8 +8599,7 @@ vect_is_simple_cond (tree cond, vec_info *vinfo,
 
   if (TREE_CODE (rhs) == SSA_NAME)
     {
-      gimple *rhs_def_stmt = SSA_NAME_DEF_STMT (rhs);
-      if (!vect_is_simple_use (rhs, vinfo, &rhs_def_stmt, &dts[1], &vectype2))
+      if (!vect_is_simple_use (rhs, vinfo, &dts[1], &vectype2))
        return false;
     }
   else if (TREE_CODE (rhs) == INTEGER_CST || TREE_CODE (rhs) == REAL_CST
@@ -8750,12 +8731,9 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi,
       || !comp_vectype)
     return false;
 
-  gimple *def_stmt;
-  if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &def_stmt, &dts[2],
-                          &vectype1))
+  if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &dts[2], &vectype1))
     return false;
-  if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &def_stmt, &dts[3],
-                          &vectype2))
+  if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &dts[3], &vectype2))
     return false;
 
   if (vectype1 && !useless_type_conversion_p (vectype, vectype1))
@@ -8892,26 +8870,24 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi,
             }
           else
             {
-             gimple *gtemp;
              if (masked)
                {
                  vec_cond_lhs
                    = vect_get_vec_def_for_operand (cond_expr, stmt,
                                                    comp_vectype);
-                 vect_is_simple_use (cond_expr, stmt_info->vinfo,
-                                     &gtemp, &dts[0]);
+                 vect_is_simple_use (cond_expr, stmt_info->vinfo, &dts[0]);
                }
              else
                {
                  vec_cond_lhs
                    = vect_get_vec_def_for_operand (cond_expr0,
                                                    stmt, comp_vectype);
-                 vect_is_simple_use (cond_expr0, loop_vinfo, &gtemp, &dts[0]);
+                 vect_is_simple_use (cond_expr0, loop_vinfo, &dts[0]);
 
                  vec_cond_rhs
                    = vect_get_vec_def_for_operand (cond_expr1,
                                                    stmt, comp_vectype);
-                 vect_is_simple_use (cond_expr1, loop_vinfo, &gtemp, &dts[1]);
+                 vect_is_simple_use (cond_expr1, loop_vinfo, &dts[1]);
                }
              if (reduc_index == 1)
                vec_then_clause = reduc_def;
@@ -8919,8 +8895,7 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi,
                {
                  vec_then_clause = vect_get_vec_def_for_operand (then_clause,
                                                                  stmt);
-                 vect_is_simple_use (then_clause, loop_vinfo,
-                                     &gtemp, &dts[2]);
+                 vect_is_simple_use (then_clause, loop_vinfo, &dts[2]);
                }
              if (reduc_index == 2)
                vec_else_clause = reduc_def;
@@ -8928,7 +8903,7 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi,
                {
                  vec_else_clause = vect_get_vec_def_for_operand (else_clause,
                                                                  stmt);
-                 vect_is_simple_use (else_clause, loop_vinfo, &gtemp, &dts[3]);
+                 vect_is_simple_use (else_clause, loop_vinfo, &dts[3]);
                }
            }
        }
@@ -9089,7 +9064,6 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi,
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
   vec<tree> vec_oprnds0 = vNULL;
   vec<tree> vec_oprnds1 = vNULL;
-  gimple *def_stmt;
   tree mask_type;
   tree mask;
 
@@ -9132,12 +9106,10 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi,
   rhs1 = gimple_assign_rhs1 (stmt);
   rhs2 = gimple_assign_rhs2 (stmt);
 
-  if (!vect_is_simple_use (rhs1, stmt_info->vinfo, &def_stmt,
-                          &dts[0], &vectype1))
+  if (!vect_is_simple_use (rhs1, stmt_info->vinfo, &dts[0], &vectype1))
     return false;
 
-  if (!vect_is_simple_use (rhs2, stmt_info->vinfo, &def_stmt,
-                          &dts[1], &vectype2))
+  if (!vect_is_simple_use (rhs2, stmt_info->vinfo, &dts[1], &vectype2))
     return false;
 
   if (vectype1 && vectype2
@@ -10043,7 +10015,7 @@ get_same_sized_vectype (tree scalar_type, tree vector_type)
    VINFO - the vect info of the loop or basic block that is being vectorized.
    OPERAND - operand in the loop or bb.
    Output:
-   DEF_STMT - the defining stmt in case OPERAND is an SSA_NAME.
+   DEF_STMT_OUT (optional) - the defining stmt in case OPERAND is an SSA_NAME.
    DT - the type of definition
 
    Returns whether a stmt with OPERAND can be vectorized.
@@ -10055,10 +10027,11 @@ get_same_sized_vectype (tree scalar_type, tree vector_type)
    For now, operands defined outside the basic block are not supported.  */
 
 bool
-vect_is_simple_use (tree operand, vec_info *vinfo,
-                    gimple **def_stmt, enum vect_def_type *dt)
+vect_is_simple_use (tree operand, vec_info *vinfo, enum vect_def_type *dt,
+                   gimple **def_stmt_out)
 {
-  *def_stmt = NULL;
+  if (def_stmt_out)
+    *def_stmt_out = NULL;
   *dt = vect_unknown_def_type;
 
   if (dump_enabled_p ())
@@ -10095,18 +10068,20 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
       return true;
     }
 
-  *def_stmt = SSA_NAME_DEF_STMT (operand);
+  gimple *def_stmt = SSA_NAME_DEF_STMT (operand);
+  if (def_stmt_out)
+    *def_stmt_out = def_stmt;
   if (dump_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location, "def_stmt: ");
-      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, *def_stmt, 0);
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, def_stmt, 0);
     }
 
-  if (! vect_stmt_in_region_p (vinfo, *def_stmt))
+  if (! vect_stmt_in_region_p (vinfo, def_stmt))
     *dt = vect_external_def;
   else
     {
-      stmt_vec_info stmt_vinfo = vinfo_for_stmt (*def_stmt);
+      stmt_vec_info stmt_vinfo = vinfo_for_stmt (def_stmt);
       *dt = STMT_VINFO_DEF_TYPE (stmt_vinfo);
     }
 
@@ -10153,7 +10128,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
       return false;
     }
 
-  switch (gimple_code (*def_stmt))
+  switch (gimple_code (def_stmt))
     {
     case GIMPLE_PHI:
     case GIMPLE_ASSIGN:
@@ -10179,12 +10154,16 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
    scalar operand.  */
 
 bool
-vect_is_simple_use (tree operand, vec_info *vinfo,
-                   gimple **def_stmt, enum vect_def_type *dt, tree *vectype)
+vect_is_simple_use (tree operand, vec_info *vinfo, enum vect_def_type *dt,
+                   tree *vectype, gimple **def_stmt_out)
 {
-  if (!vect_is_simple_use (operand, vinfo, def_stmt, dt))
+  gimple *def_stmt;
+  if (!vect_is_simple_use (operand, vinfo, dt, &def_stmt))
     return false;
 
+  if (def_stmt_out)
+    *def_stmt_out = def_stmt;
+
   /* Now get a vector type if the def is internal, otherwise supply
      NULL_TREE and leave it up to the caller to figure out a proper
      type for the use stmt.  */
@@ -10194,7 +10173,7 @@ vect_is_simple_use (tree operand, vec_info *vinfo,
       || *dt == vect_double_reduction_def
       || *dt == vect_nested_cycle)
     {
-      stmt_vec_info stmt_info = vinfo_for_stmt (*def_stmt);
+      stmt_vec_info stmt_info = vinfo_for_stmt (def_stmt);
 
       if (STMT_VINFO_IN_PATTERN_P (stmt_info)
           && !STMT_VINFO_RELEVANT (stmt_info)
@@ -10869,13 +10848,11 @@ vect_get_mask_type_for_stmt (stmt_vec_info stmt_info)
     {
       tree rhs;
       ssa_op_iter iter;
-      gimple *def_stmt;
       enum vect_def_type dt;
 
       FOR_EACH_SSA_TREE_OPERAND (rhs, stmt, iter, SSA_OP_USE)
        {
-         if (!vect_is_simple_use (rhs, stmt_info->vinfo,
-                                  &def_stmt, &dt, &vectype))
+         if (!vect_is_simple_use (rhs, stmt_info->vinfo, &dt, &vectype))
            {
              if (dump_enabled_p ())
                {
index a8406b3df7a126868dc3373aed34f7377a993898..2dac54e3e3275f0fbf7e0bf39e4e4427de36c0de 100644 (file)
@@ -1477,10 +1477,10 @@ extern tree get_vectype_for_scalar_type_and_size (tree, poly_uint64);
 extern tree get_mask_type_for_scalar_type (tree);
 extern tree get_same_sized_vectype (tree, tree);
 extern bool vect_get_loop_mask_type (loop_vec_info);
-extern bool vect_is_simple_use (tree, vec_info *, gimple **,
-                                enum vect_def_type *);
-extern bool vect_is_simple_use (tree, vec_info *, gimple **,
-                               enum vect_def_type *, tree *);
+extern bool vect_is_simple_use (tree, vec_info *, enum vect_def_type *,
+                               gimple ** = NULL);
+extern bool vect_is_simple_use (tree, vec_info *, enum vect_def_type *,
+                               tree *, gimple ** = NULL);
 extern bool supportable_widening_operation (enum tree_code, gimple *, tree,
                                            tree, enum tree_code *,
                                            enum tree_code *, int *,