I cut&pasted the wrong type to one of the calls.  For debugging
I added missing mask precision dumpings.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        PR tree-optimization/127116
        * tree-vect-patterns.cc (vect_recog_mask_conversion_pattern):
        Pass rhs1_type as scalar type to build_mask_conversion.
        (vect_init_pattern_stmt): Dump mask-precision used for the stmt.
        (append_pattern_def_seq): Likewise.

        * gcc.dg/vect/bb-slp-pr127116.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/bb-slp-pr127116.c | 81 +++++++++++++++++++++
 gcc/tree-vect-patterns.cc                   | 32 +++++++-
 2 files changed, 110 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr127116.c

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr127116.c 
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr127116.c
new file mode 100644
index 00000000000..f6a2194ffb3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr127116.c
@@ -0,0 +1,81 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fgimple" } */
+
+struct a {
+  short b;
+  unsigned c;
+} volatile d;
+struct a e;
+struct a f;
+int __GIMPLE (ssa,guessed_local(214748368),startwith("slp"))
+g (int ab)
+{
+  short e__lsm$13;
+  short int _1;
+  unsigned int _2;
+  bool _3;
+  bool _4;
+  bool _5;
+  short int _6;
+  short int _7;
+  bool _11;
+  unsigned char _13;
+  short int _14;
+  unsigned char _16;
+  unsigned char _17;
+  bool _30;
+  bool _31;
+  short int _32;
+  short int _33;
+  short int _40;
+  bool _41;
+  unsigned char _43;
+  bool _44;
+  bool _45;
+  short int _46;
+  short int _47;
+  short int _54;
+  bool _55;
+  unsigned char _57;
+  bool _58;
+  bool _59;
+  short int _60;
+  short int _61;
+
+  __BB(2,guessed_local(214748370)):
+  _2 = f.c;
+  _13 = (unsigned char) _2;
+  e__lsm$13_9 = __MEM <short> ((short *)&e);
+  _14 = d.b;
+  _5 = _14 == _Literal (short int) 0;
+  _17 = _13 * _Literal (unsigned char) 252;
+  _30 = _17 == _Literal (unsigned char) 6;
+  _31 = _30 <= _5;
+  _32 = (short int) _31;
+  _33 = e__lsm$13_9 | _32;
+  _40 = d.b;
+  _41 = _40 == _Literal (short int) 0;
+  _43 = _13 * _Literal (unsigned char) 253;
+  _44 = _43 == _Literal (unsigned char) 6;
+  _45 = _44 <= _41;
+  _46 = (short int) _45;
+  _47 = _33 | _46;
+  _54 = d.b;
+  _55 = _54 == _Literal (short int) 0;
+  _57 = _13 * _Literal (unsigned char) 254;
+  _58 = _57 == _Literal (unsigned char) 6;
+  _59 = _58 <= _55;
+  _60 = (short int) _59;
+  _61 = _47 | _60;
+  _1 = d.b;
+  _11 = _1 == _Literal (short int) 0;
+  _16 = -_13;
+  _3 = _16 == _Literal (unsigned char) 6;
+  _4 = _3 <= _11;
+  _6 = (short int) _4;
+  _7 = _6 | _61;
+  __MEM <short> ((short *)&e) = _7;
+  return;
+}
+
+
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 406f81b95c8..4f450763a1c 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -138,6 +138,18 @@ vect_init_pattern_stmt (vec_info *vinfo, gimple 
*pattern_stmt,
                      == vect_use_mask_type_p (orig_stmt_info)));
       STMT_VINFO_VECTYPE (pattern_stmt_info) = vectype;
       pattern_stmt_info->mask_precision = orig_stmt_info->mask_precision;
+      if (dump_enabled_p ())
+       {
+         if (pattern_stmt_info->mask_precision == ~0U)
+           dump_printf_loc (MSG_NOTE, vect_location,
+                            "using normal nonmask vectors for %G",
+                            pattern_stmt_info->stmt);
+         else
+           dump_printf_loc (MSG_NOTE, vect_location,
+                            "using boolean precision %d for %G",
+                            pattern_stmt_info->mask_precision,
+                            pattern_stmt_info->stmt);
+       }
     }
   return pattern_stmt_info;
 }
@@ -174,8 +186,22 @@ append_pattern_def_seq (vec_info *vinfo,
       stmt_vec_info new_stmt_info = vinfo->add_stmt (new_stmt);
       STMT_VINFO_VECTYPE (new_stmt_info) = vectype;
       if (scalar_type_for_mask)
-       new_stmt_info->mask_precision
-         = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (scalar_type_for_mask));
+       {
+         new_stmt_info->mask_precision
+           = GET_MODE_BITSIZE (SCALAR_TYPE_MODE (scalar_type_for_mask));
+         if (dump_enabled_p ())
+           {
+             if (new_stmt_info->mask_precision == ~0U)
+               dump_printf_loc (MSG_NOTE, vect_location,
+                                "using normal nonmask vectors for %G",
+                                new_stmt_info->stmt);
+             else
+               dump_printf_loc (MSG_NOTE, vect_location,
+                                "using boolean precision %d for %G",
+                                new_stmt_info->mask_precision,
+                                new_stmt_info->stmt);
+           }
+       }
     }
   gimple_seq_add_stmt_without_update (&STMT_VINFO_PATTERN_DEF_SEQ (stmt_info),
                                      new_stmt);
@@ -6471,7 +6497,7 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
       if (!vectype1)
        return NULL;
       rhs2 = build_mask_conversion (vinfo, rhs2, vectype1, stmt_vinfo,
-                                   rhs2_type);
+                                   rhs1_type);
     }
   else
     {
-- 
2.51.0

Reply via email to