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

            Bug ID: 124491
           Summary: [14/15 Regression] ICE in fold_vec_perm during ccp
                    with -msve-vector-bits=256
           Product: gcc
           Version: 15.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

The following fails on the 15 and 14 branches:

$ cat t.c
#include <arm_sve.h>
svint64_t foo(long x, long y) {
  return svdupq_n_s64(x, y);
}
$ ./xgcc -B . -c t.c -S -o /dev/null -O2 -march=armv8.2-a+sve
-msve-vector-bits=256
during GIMPLE pass: ccp
t.c: In function ‘foo’:
t.c:4:1: internal compiler error: in fold_vec_perm, at fold-const.cc:10691
    4 | }
      | ^
0x31c302f internal_error(char const*, ...)
        $SRC/15/gcc/diagnostic-global-context.cc:517
0x3195bbb fancy_abort(char const*, int, char const*)
        $SRC/15/gcc/diagnostic.cc:1749
0x12996b3 fold_vec_perm(tree_node*, tree_node*, tree_node*, vec_perm_indices
const&)
        $SRC/15/gcc/fold-const.cc:10691
0x227bc53 gimple_simplify_VEC_PERM_EXPR(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*, tree_node*)
        /work/builds/dbg/15/gcc/gimple-match-10.cc:23603
0x1f5f5b3 gimple_simplify(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*, tree_node*)
        /work/builds/dbg/15/gcc/gimple-match-3.cc:19085
0x228106f gimple_resimplify3
        $SRC/15/gcc/gimple-match-exports.cc:1128
0x227e4db gimple_match_op::resimplify(gimple**, tree_node* (*)(tree_node*))
        $SRC/15/gcc/gimple-match-exports.cc:115
0x22803a3 gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), tree_node* (*)(tree_node*))
        $SRC/15/gcc/gimple-match-exports.cc:919
0x131b1f7 gimple_fold_stmt_to_constant_1(gimple*, tree_node* (*)(tree_node*),
tree_node* (*)(tree_node*))
        $SRC/15/gcc/gimple-fold.cc:9306
0x19297af ccp_fold
        $SRC/15/gcc/tree-ssa-ccp.cc:1303
0x192da1f evaluate_stmt
        $SRC/15/gcc/tree-ssa-ccp.cc:2266
0x192f973 visit_assignment
        $SRC/15/gcc/tree-ssa-ccp.cc:2901
0x192fc43 ccp_propagate::visit_stmt(gimple*, edge_def**, tree_node**)
        $SRC/15/gcc/tree-ssa-ccp.cc:2974
0x1a090a7 ssa_propagation_engine::simulate_stmt(gimple*)
        $SRC/15/gcc/tree-ssa-propagate.cc:221
0x1a09577 ssa_propagation_engine::simulate_block(basic_block_def*)
        $SRC/15/gcc/tree-ssa-propagate.cc:328
0x1a09cf3 ssa_propagation_engine::ssa_propagate()
        $SRC/15/gcc/tree-ssa-propagate.cc:478
0x192fdc7 do_ssa_ccp
        $SRC/15/gcc/tree-ssa-ccp.cc:3020
0x192ff83 execute
        $SRC/15/gcc/tree-ssa-ccp.cc:3066
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

I did some bisection and the timeline looks to be as follows:

r14-2134-g231f6b56c77c50: we start lowering svdupq to VEC_PERM_EXPR for
non-constant arguments, ICE begins
r16-6709-ga4716ece529dfd: fix for middle-end/123175: ICE changed from
fold_vec_perm to invalid GIMPLE
r16-6743-ge787d5ace5cc31: fix for middle-end/123573: invalid gimple ICE fixed

With the r16-6709 rev alone we get invalid GIMPLE.  In ccp1 we have:

svint64_t foo (long int x, long int y)
{
  vector(2) long int _1;
  svint64_t _4;

  <bb 2> :
  _1 = {x_2(D), y_3(D)};
  _4 = VEC_PERM_EXPR <_1, _1, { 0, 1, 0, 1 }>;
  return _4;

}

but then in forwprop we get:

svint64_t foo (long int x, long int y)
{
  vector(2) long int _1;
  svint64_t _4;

  <bb 2> :
  _1 = {x_2(D), y_3(D)};
  _4 = _1;
  return _4;

}

gimple verification then fails with:

t.c:4:1: error: non-trivial conversion in ‘ssa_name’
    4 | }
      | ^
svint64_t
vector(2) long int
_4 = _1;
during GIMPLE pass: forwprop

on trunk we don't fold the VEC_PERM_EXPR away, which seems correct.  So it
would appear that we need both the GCC 16 revs backporting to the 15 and 14
branches.

WDYT, richi? Are you able to take care of this or would you like us to do it?

Reply via email to