gcc-9.0.0-alpha20180520 snapshot (r260425) and 8.1 ICE (differently) when compiling the following snippet w/ -mavx512vbmi -O1 (-O2) -ftree-loop-vectorize: int uf; int l7 (int wk, int sv) { while (sv < 1) { int me; for (me = 0; me < 64; ++me) wk += !!((unsigned char) sv) && (!!uf == !!me); ++sv; } return wk; } % x86_64-unknown-linux-gnu-gcc-9.0.0-alpha20180520 -mavx512vbmi -O1 -ftree-loop-vectorize -c qfoifajc.c qfoifajc.c: In function 'l7': qfoifajc.c:4:1: error: type mismatch in vector pack expression l7 (int wk, int sv) ^~ <unnamed type> <unnamed type> <unnamed type> _84 = VEC_PACK_TRUNC_EXPR <_131, _85>; during GIMPLE pass: veclower2 qfoifajc.c:4:1: internal compiler error: verify_gimple failed 0xce6f99 verify_gimple_in_cfg(function*, bool) /var/tmp/portage/sys-devel/gcc-9.0.0_alpha20180520/work/gcc-9-20180520/gcc/tree-cfg.c:5347 0xbc198f execute_function_todo /var/tmp/portage/sys-devel/gcc-9.0.0_alpha20180520/work/gcc-9-20180520/gcc/passes.c:1994 0xbc28de execute_todo /var/tmp/portage/sys-devel/gcc-9.0.0_alpha20180520/work/gcc-9-20180520/gcc/passes.c:2048 and gcc 8.1: during RTL pass: expand <source>: In function 'l7': <source>:4:1: internal compiler error: in emit_move_insn, at expr.c:3722 l7 (int wk, int sv) ^~
Confirmed, started with r247048.
The issue is that vector lowering does anything to the vectorized code, that is, a disconnect between what the vectorizer thinks the target can do and what vector lowering thinks. And then some bug in vector lowering generating sth "stupid" for mask vector lowerings. Ah, it runs into /* If the vector operation is operating on all same vector elements implement it with a scalar operation and a splat if the target supports the scalar operation. */ tree srhs1, srhs2 = NULL_TREE; if ((srhs1 = ssa_uniform_vector_p (rhs1)) != NULL_TREE && (rhs2 == NULL_TREE || (! VECTOR_TYPE_P (TREE_TYPE (rhs2)) && (srhs2 = rhs2)) || (srhs2 = ssa_uniform_vector_p (rhs2)) != NULL_TREE) /* As we query direct optabs restrict to non-convert operations. */ && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (TREE_TYPE (srhs1))) { op = optab_for_tree_code (code, TREE_TYPE (type), optab_scalar); if (op >= FIRST_NORM_OPTAB && op <= LAST_NORM_OPTAB && optab_handler (op, TYPE_MODE (TREE_TYPE (type))) != CODE_FOR_nothing) { for vector boolean operations to optimize ~{_88,_88...} to {~_88,~_88...}. And then it ends up doing this to mask_patt_63.10_95 = VEC_PACK_TRUNC_EXPR <mask__43.8_92, mask__43.8_93>; but of course this trick doesn't work for that and the optab query is "confused" here because the vector mode is QImode and the component mode is QImode as well. The easiest fix is to hoist the VECTOR_BOOLEAN_TYPE_P check above this transform.
Author: rguenth Date: Mon May 28 10:28:38 2018 New Revision: 260847 URL: https://gcc.gnu.org/viewcvs?rev=260847&root=gcc&view=rev Log: 2018-05-28 Richard Biener <rguenther@suse.de> PR tree-optimization/85934 * tree-vect-generic.c (expand_vector_operations_1): Hoist vector boolean check before scalar optimization. * gcc.target/i386/pr85934.c: New testcase. Added: trunk/gcc/testsuite/gcc.target/i386/pr85934.c Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vect-generic.c
Fixed on trunk sofar.
Author: rguenth Date: Wed Jun 6 15:06:50 2018 New Revision: 261237 URL: https://gcc.gnu.org/viewcvs?rev=261237&root=gcc&view=rev Log: 2018-06-06 Richard Biener <rguenther@suse.de> Backport from mainline 2018-06-04 Richard Biener <rguenther@suse.de> PR tree-optimization/86038 * tracer.c (find_best_successor): Check probability for being initialized, bail out if not. * gcc.dg/pr86038.c: New testcase. 2018-05-30 Richard Biener <rguenther@suse.de> PR tree-optimization/85964 * tracer.c (better_p): Drop initialized count check, we only call the function with initialized counts now. (find_best_successor): Do find a best edge if one has uninitialized count. (find_best_predecessor): Likewise. Do BB frequency check only if count is initialized. 2018-05-28 Richard Biener <rguenther@suse.de> PR tree-optimization/85934 * tree-vect-generic.c (expand_vector_operations_1): Hoist vector boolean check before scalar optimization. * gcc.target/i386/pr85934.c: New testcase. 2018-05-22 Richard Biener <rguenther@suse.de> PR tree-optimization/85863 * tree-vect-stmts.c (vect_is_simple_cond): Only widen invariant comparisons when vectype is specified. (vectorizable_condition): Do not specify vectype for vect_is_simple_cond when SLP vectorizing. * gfortran.fortran-torture/compile/pr85863.f: New testcase. Added: branches/gcc-8-branch/gcc/testsuite/gcc.dg/pr86038.c branches/gcc-8-branch/gcc/testsuite/gcc.target/i386/pr85934.c branches/gcc-8-branch/gcc/testsuite/gfortran.fortran-torture/compile/pr85863.f Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/testsuite/ChangeLog branches/gcc-8-branch/gcc/tracer.c branches/gcc-8-branch/gcc/tree-vect-generic.c branches/gcc-8-branch/gcc/tree-vect-stmts.c
Fixed.