Bug 85934 - [8 Regression] ICE: verify_gimple failed (error: type mismatch in vector pack expression)
Summary: [8 Regression] ICE: verify_gimple failed (error: type mismatch in vector pack...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 8.1.0
: P2 normal
Target Milestone: 8.2
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-05-26 03:27 UTC by Arseny Solokha
Modified: 2018-06-06 15:08 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work: 8.1.1, 9.0
Known to fail: 8.1.0
Last reconfirmed: 2018-05-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2018-05-26 03:27:38 UTC
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)
 ^~
Comment 1 Martin Liška 2018-05-28 06:54:05 UTC
Confirmed, started with r247048.
Comment 2 Richard Biener 2018-05-28 07:39:32 UTC
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.
Comment 3 Richard Biener 2018-05-28 10:29:10 UTC
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
Comment 4 Richard Biener 2018-05-28 10:29:25 UTC
Fixed on trunk sofar.
Comment 5 Richard Biener 2018-06-06 15:07:23 UTC
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
Comment 6 Richard Biener 2018-06-06 15:08:10 UTC
Fixed.