[Bug tree-optimization/78997] [7 regression] ICE on valid code at -O3 on x86_64-linux-gnu: verify_gimple failed

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 5 11:41:00 GMT 2017


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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Built by

#2  0x00000000011c1759 in vectorizable_condition (
    stmt=<gimple_assign 0x2aaaac149e40>, gsi=0x7fffffffd460, 
    vec_stmt=0x7fffffffd378, reduc_def=<tree 0x0>, reduc_index=0, 
    slp_node=0x296b8a0)
    at /space/rguenther/src/svn/gcc-7-branch/gcc/tree-vect-stmts.c:7962
7962                                              vec_else_clause);
(gdb) l
7957                                        vec_cond_lhs, vec_cond_rhs);
7958                }
7959              new_temp = make_ssa_name (vec_dest);
7960              new_stmt = gimple_build_assign (new_temp, VEC_COND_EXPR,
7961                                              vec_compare, vec_then_clause,
7962                                              vec_else_clause);
7963              vect_finish_stmt_generation (stmt, new_stmt, gsi);
7964              if (slp_node)
7965                SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt);
7966            }

masked is true.

_ifc__822 = _898 ? _ifc__823 : _ifc__824;

with _898 _Bool and the type of the cond being short int.  We properly compute
comp_vectype to V8HI but the SLP defs are V16QI.

Not sure where we are supposed to fix this up (or reject vectorization).  But
it looks like

_898 = _854 & _879;

is in a pattern patt_711 = _854 & patt_712;

and that has a VECTYPE of V8HI (but ends up being vectorized as V16QI because
the LHS type is still _Bool).

The SLP node has different COND_EXPRs with all the same condition btw.

t.c:16:6: note: vect_recog_mask_conversion_pattern: detected:
t.c:16:6: note: mask_conversion pattern recognized: patt_711 = _854 & patt_712;

ah, and we're building the SLP node with the condition from scalars!  That's
where things must go wrong...

t.c:16:6: note: Final SLP tree for instance:
t.c:16:6: note: node
t.c:16:6: note:         stmt 0 bc[2] = _ifc__822;
t.c:16:6: note:         stmt 1 bc[3] = _ifc__819;
t.c:16:6: note:         stmt 2 bc[4] = _ifc__816;
t.c:16:6: note:         stmt 3 bc[5] = _ifc__813;
t.c:16:6: note:         stmt 4 bc[6] = _ifc__810;
t.c:16:6: note:         stmt 5 bc[7] = _ifc__807;
t.c:16:6: note:         stmt 6 bc[8] = _ifc__804;
t.c:16:6: note:         stmt 7 bc[9] = _ifc__801;
t.c:16:6: note: node
t.c:16:6: note:         stmt 0 _ifc__822 = _898 ? _ifc__823 : _ifc__824;
t.c:16:6: note:         stmt 1 _ifc__819 = _898 ? _ifc__820 : _ifc__821;
t.c:16:6: note:         stmt 2 _ifc__816 = _898 ? _ifc__817 : _ifc__818;
t.c:16:6: note:         stmt 3 _ifc__813 = _898 ? _ifc__814 : _ifc__815;
t.c:16:6: note:         stmt 4 _ifc__810 = _898 ? _ifc__811 : _ifc__812;
t.c:16:6: note:         stmt 5 _ifc__807 = _898 ? _ifc__808 : _ifc__809;
t.c:16:6: note:         stmt 6 _ifc__804 = _898 ? _ifc__805 : _ifc__806;
t.c:16:6: note:         stmt 7 _ifc__801 = _898 ? _ifc__802 : _ifc__803;
t.c:16:6: note: node (external)
t.c:16:6: note:         stmt 0 patt_711 = _854 & patt_712;
t.c:16:6: note:         stmt 1 patt_711 = _854 & patt_712;
t.c:16:6: note:         stmt 2 patt_711 = _854 & patt_712;
...

OTOH vect_recog_mask_conversion_pattern looks somewhat odd -- we end up
with a pattern stmt _Bool(QI) = _Bool(QI) & _Bool(HI);


Fix that works for the testcase:

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c (revision 244093)
+++ gcc/tree-vect-slp.c (working copy)
@@ -2897,9 +2897,8 @@ vect_mask_constant_operand_p (gimple *st
       tree cond = gimple_assign_rhs1 (stmt);

       if (TREE_CODE (cond) == SSA_NAME)
-       return false;
-
-      if (opnum)
+       op = cond;
+      else if (opnum)
        op = TREE_OPERAND (cond, 1);
       else
        op = TREE_OPERAND (cond, 0);


More information about the Gcc-bugs mailing list