https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98211

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so I think

x.c:41:31: note:   === vect_pattern_recog ===
x.c:41:31: note:   vect_recog_mask_conversion_pattern: detected: iftmp.2_10 =
_26 != 0 ? iftmp.2_22 : iftmp.2_21;
x.c:41:31: note:   mask_conversion pattern recognized: patt_95 = patt_91 ?
iftmp.2_22 : iftmp.2_21;
x.c:41:31: note:   extra pattern stmt: patt_87 = (<signed-boolean:8>) _26;
x.c:41:31: note:   extra pattern stmt: patt_84 = patt_87 != 0;
x.c:41:31: note:   extra pattern stmt: patt_91 = (<signed-boolean:16>) patt_84;

needs to be recognized as bool pattern and thus this is a pattern ordering
issue and vect_recog_bool_pattern has to come after
vect_recog_mask_conversion_pattern.  Now I'm sure there's a thing the other way
around :/

diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index f2ce75aac3e..6a5f9505792 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -5267,12 +5267,12 @@ static vect_recog_func vect_vect_recog_func_ptrs[] = {
   { vect_recog_divmod_pattern, "divmod" },
   { vect_recog_mult_pattern, "mult" },
   { vect_recog_mixed_size_cond_pattern, "mixed_size_cond" },
-  { vect_recog_bool_pattern, "bool" },
   /* This must come before mask conversion, and includes the parts
      of mask conversion that are needed for gather and scatter
      internal functions.  */
   { vect_recog_gather_scatter_pattern, "gather_scatter" },
   { vect_recog_mask_conversion_pattern, "mask_conversion" },
+  { vect_recog_bool_pattern, "bool" },
   { vect_recog_widen_plus_pattern, "widen_plus" },
   { vect_recog_widen_minus_pattern, "widen_minus" },
 };

fixes the testcase and properly recognizes

x.c:41:31: note:   vect_recog_mask_conversion_pattern: detected: iftmp.2_10 =
_26 != 0 ? iftmp.2_22 : iftmp.2_21;
x.c:41:31: note:   mask_conversion pattern recognized: patt_95 = patt_91 ?
iftmp.2_22 : iftmp.2_21;
x.c:41:31: note:   extra pattern stmt: patt_87 = (<signed-boolean:8>) _26;
x.c:41:31: note:   extra pattern stmt: patt_84 = patt_87 != 0;
x.c:41:31: note:   extra pattern stmt: patt_91 = (<signed-boolean:16>) patt_84;
x.c:41:31: note:   vect_recog_bool_pattern: detected: patt_87 =
(<signed-boolean:8>) _26;
x.c:41:31: note:   bool pattern recognized: patt_103 = (<signed-boolean:8>)
patt_99;
x.c:41:31: note:   replacing earlier pattern patt_87 = (<signed-boolean:8>)
_26;
x.c:41:31: note:   with patt_87 = (<signed-boolean:8>) patt_99;
x.c:41:31: note:   extra pattern stmt: patt_99 = _26 ? 1 : 0;
x.c:41:31: note:   vect_recog_bool_pattern: detected: patt_91 =
(<signed-boolean:16>) patt_84;
x.c:41:31: note:   bool pattern recognized: patt_111 = (<signed-boolean:16>)
patt_107;
x.c:41:31: note:   replacing earlier pattern patt_91 = (<signed-boolean:16>)
patt_84;
x.c:41:31: note:   with patt_91 = (<signed-boolean:16>) patt_107;
x.c:41:31: note:   extra pattern stmt: patt_107 = patt_84 ? 1 : 0;

Reply via email to