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

            Bug ID: 71294
           Summary: [6/7 Regression] ICE in gen_add2_insn, at
                    optabs.c:4442 on powerpc64le-linux
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

Hello.

Following code snippet fails with:
./xgcc -B. -O3 -fstack-protector ice2.ii
ice2.ii: In function ‘void fn1()’:
ice2.ii:51:1: internal compiler error: in gen_add2_insn, at optabs.c:4442
 }
 ^
0xc00edb gen_add2_insn(rtx_def*, rtx_def*)
        ../../gcc/optabs.c:4442
0xc768b4 gen_reload
        ../../gcc/reload1.c:8710
0xc7a35e emit_input_reload_insns
        ../../gcc/reload1.c:7664
0xc7b3bc do_input_reload
        ../../gcc/reload1.c:7950
0xc7b3bc emit_reload_insns
        ../../gcc/reload1.c:8142
0xc7dd69 reload_as_needed
        ../../gcc/reload1.c:4661
0xc81a7b reload(rtx_insn*, int)
        ../../gcc/reload1.c:1062
0xb39da2 do_reload
        ../../gcc/ira.c:5393
0xb39da2 execute
        ../../gcc/ira.c:5565

$ cat ice2.ii
class A;
template <typename _Tp, int m, int n> class B {
public:
  _Tp val[m * n];
};
class C {
public:
  C(A);
};
struct D {
  D();
  unsigned long &operator[](int);
  unsigned long *p;
};
class A {
public:
  template <typename _Tp, int m, int n> A(const B<_Tp, m, n> &, bool);
  int rows, cols;
  unsigned char *data;
  unsigned char *datastart;
  unsigned char *dataend;
  unsigned char *datalimit;
  D step;
};
template <typename _Tp, int m, int n>
A::A(const B<_Tp, m, n> &p1, bool)
    : rows(m), cols(n) {
  step[0] = cols * sizeof(_Tp);
  datastart = data = (unsigned char *)p1.val;
  datalimit = dataend = datastart + rows * step[0];
}
class F {
public:
  static void compute(C);
  template <typename _Tp, int m, int n, int nm>
  static void compute(const B<_Tp, m, n> &, B<_Tp, nm, 1> &, B<_Tp, m, nm> &,
                      B<_Tp, n, nm> &);
};
D::D() {}
unsigned long &D::operator[](int p1) { return p[p1]; }
template <typename _Tp, int m, int n, int nm>
void F::compute(const B<_Tp, m, n> &, B<_Tp, nm, 1> &, B<_Tp, m, nm> &,
                B<_Tp, n, nm> &p4) {
  A a(p4, false);
  compute(a);
}
void fn1() {
  B<double, 4, 4> b, c, e;
  B<double, 4, 1> d;
  F::compute(b, d, c, e);
}

gcc version 5.2.1 works fine.

Martin

Reply via email to