Bug 95356 - [11 Regression] ICE in vect_get_constant_vectors, at tree-vect-slp.c:3635 since r11-564-g79f0451c67e8ed56
Summary: [11 Regression] ICE in vect_get_constant_vectors, at tree-vect-slp.c:3635 sin...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
: 95357 95358 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-05-27 06:58 UTC by Martin Liška
Modified: 2020-05-29 10:53 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-05-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2020-05-27 06:58:09 UTC
I see this:

$ gcc /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/vshift-5.c -O3 -mavx512dq
during GIMPLE pass: slp
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/vshift-5.c: In function ‘f1’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/vshift-5.c:8:1: internal compiler error: in vect_get_constant_vectors, at tree-vect-slp.c:3655
    8 | f1 (void)
      | ^~
0x767911 vect_get_constant_vectors
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:3655
0x10d1cba vect_get_slp_defs(vec_info*, _slp_tree*, vec<vec<tree_node*, va_heap, vl_ptr>, va_heap, vl_ptr>*, unsigned int)
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:3887
0x108ba57 vect_get_vec_defs(vec_info*, tree_node*, tree_node*, _stmt_vec_info*, vec<tree_node*, va_heap, vl_ptr>*, vec<tree_node*, va_heap, vl_ptr>*, _slp_tree*)
	/home/marxin/Programming/gcc/gcc/tree-vect-stmts.c:1636
0x109124d vectorizable_shift
	/home/marxin/Programming/gcc/gcc/tree-vect-stmts.c:5900
0x10a855e vect_transform_stmt(vec_info*, _stmt_vec_info*, gimple_stmt_iterator*, _slp_tree*, _slp_instance*)
	/home/marxin/Programming/gcc/gcc/tree-vect-stmts.c:11182
0x10cf7d8 vect_schedule_slp_instance
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:4235
0x10cf888 vect_schedule_slp_instance
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:4127
0x10d8812 vect_schedule_slp(vec_info*)
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:4359
0x10db80c vect_slp_bb_region
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:3318
0x10db80c vect_slp_bb(basic_block_def*)
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:3441
0x10dd1bf execute
	/home/marxin/Programming/gcc/gcc/tree-vectorizer.c:1320
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Richard Biener 2020-05-27 08:07:58 UTC
Mine.
Comment 2 Richard Biener 2020-05-27 09:42:24 UTC
So we get v4si for the vector type but the operand is long long int:

3683        gcc_assert (vector_type
3684                    && types_compatible_p (vector_type,
3685                                           get_vectype_for_scalar_type
3686                                             (vinfo, TREE_TYPE (op), op_node)));

this is because vectorizable_shift is somewhat of a mess.  Fixinig.
Comment 3 Richard Biener 2020-05-27 09:54:48 UTC
*** Bug 95358 has been marked as a duplicate of this bug. ***
Comment 4 Richard Biener 2020-05-27 09:58:06 UTC
*** Bug 95357 has been marked as a duplicate of this bug. ***
Comment 5 GCC Commits 2020-05-27 12:10:22 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:764ef40ba185ef9245a209ba9260d1e50bec6934

commit r11-658-g764ef40ba185ef9245a209ba9260d1e50bec6934
Author: Richard Biener <rguenther@suse.de>
Date:   Wed May 27 11:42:35 2020 +0200

    tree-optimization/95356 - fix vectorizable_shift vector types
    
    This makes sure to always use the same vector type for the shift
    operand as for the shifted operand.
    
    2020-05-27  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95356
            * tree-vect-stmts.c (vectorizable_shift): Adjust vector
            type for the shift operand.
Comment 6 Richard Biener 2020-05-27 12:10:33 UTC
Fixed.
Comment 7 GCC Commits 2020-05-28 09:55:53 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:09df85393ce5501a28359d159670fd05c4d70abf

commit r11-687-g09df85393ce5501a28359d159670fd05c4d70abf
Author: Richard Biener <rguenther@suse.de>
Date:   Thu May 28 10:27:48 2020 +0200

    tree-optimization/95273 - more vectorizable_shift massaging
    
    Covering all bases in vectorizable_shift is hard - this makes sure
    to appropriately handle the case of PR95356 without breaking others.
    
    2020-05-28  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95273
            PR tree-optimization/95356
            * tree-vect-stmts.c (vectorizable_shift): Adjust when and to
            what we set the vector type of the shift operand SLP node
            again.
    
            * gcc.target/i386/pr95356.c: New testcase.
Comment 8 Richard Biener 2020-05-28 12:19:36 UTC
FAILs again.
Comment 9 Martin Liška 2020-05-28 12:19:59 UTC
Reopening as the following is ICEing:

$ gcc /home/marxin/Programming/gcc/gcc/testsuite/gcc.target/i386/pr95356.c -c -O3 -mavx512dq
during GIMPLE pass: slp
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/i386/pr95356.c: In function ‘f1’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.target/i386/pr95356.c:8:1: internal compiler error: in vect_create_constant_vectors, at tree-vect-slp.c:3674
    8 | f1 (void)
      | ^~
0x769846 vect_create_constant_vectors
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:3674
0x769846 vect_schedule_slp_instance
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:4066
0x10d3508 vect_schedule_slp_instance
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:4071
0x10d3508 vect_schedule_slp_instance
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:4071
0x10d9552 vect_schedule_slp(vec_info*)
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:4303
0x10dbffc vect_slp_bb_region
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:3342
0x10dbffc vect_slp_bb(basic_block_def*)
	/home/marxin/Programming/gcc/gcc/tree-vect-slp.c:3465
0x10dd9ef execute
	/home/marxin/Programming/gcc/gcc/tree-vectorizer.c:1320
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 10 Richard Biener 2020-05-28 12:22:23 UTC
OK, so vectorizable_shift doing

              else if (dt[1] == vect_constant_def)
                {
                  /* Convert the scalar constant shift amounts in-place.  */
                  slp_tree shift = SLP_TREE_CHILDREN (slp_node)[1];
                  gcc_assert (SLP_TREE_DEF_TYPE (shift) == vect_constant_def);
                  for (unsigned i = 0;
                       i < SLP_TREE_SCALAR_OPS (shift).length (); ++i)
                    {
                      SLP_TREE_SCALAR_OPS (shift)[i]
                          = fold_convert (TREE_TYPE (vectype),
                                          SLP_TREE_SCALAR_OPS (shift)[i]);
                      gcc_assert ((TREE_CODE (SLP_TREE_SCALAR_OPS (shift)[i])
                                   == INTEGER_CST));
                    }

no longer works because we already tried code-generating it.  The above would
need to happen at analysis time (ensuring the node is not shared - which would
be a problem for the above code as well).
Comment 11 GCC Commits 2020-05-29 10:53:09 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:ddf90b72d2a723decc487db6d3131846b9a618de

commit r11-717-gddf90b72d2a723decc487db6d3131846b9a618de
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 29 10:46:06 2020 +0200

    tree-optimization/95356 - more vectorizable_shift massaging
    
    The previous fix clashed with the rewrite to emit SLP invariants
    during the SLP walk.  Thus the following adjusts the SLP tree
    hacking vectorizable_shift does appropriately.
    
    Still resisting the attempt of a rewrite of vectorizable_shift ...
    
    2020-05-29  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/95356
            * tree-vect-stmts.c (vectorizable_shift): Do in-place SLP
            node hacking during analysis.
Comment 12 Richard Biener 2020-05-29 10:53:39 UTC
Fixed again.