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

            Bug ID: 127323
           Summary: ICE in extract_integral_bit_field building povray.
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rdapp at gcc dot gnu.org
  Target Milestone: ---
            Target: riscv

Jeff reported that since r17-3908-g0b67b93cfe0a67 (setting REGMODE_NATURAL_SIZE
properly on riscv), we're seeing an ICE building povray.

The signature is:

0x53eb6e extract_integral_bit_field                                             
        ../../gcc/expmed.cc:2025                                                
0xd4f4ac extract_bit_field(rtx_def*, poly_int<2u, unsigned long>, poly_int<2u,
unsigned long>, int, rtx_def*, machine_mode, machine_mode, bool, rtx_def**)     
        ../../gcc/expmed.cc:2233                                                
0xd6ea23 expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)                                               
        ../../gcc/expr.cc:12672

Reduced reproducer:

typedef double VECTOR[3];
enum { X, Y, Z };
struct Bicubic_Patch_Struct {
  VECTOR Control_Points[4][4];
  VECTOR Bounding_Sphere_Center;
  double Bounding_Sphere_Radius;
};
void Assign_Vector(VECTOR d, VECTOR s) {
  d[X] = s[X];
  d[Y] = s[Y];
  d[Z] = s[Z];
}
typedef struct Bicubic_Patch_Struct BICUBIC_PATCH;
namespace std {
void find_average(int vector_count, VECTOR *vectors, VECTOR, double *radius) {
  int i;
  double r0, r1, yc, zc, y0;
  for (i = 0; i < vector_count; i++) {
    yc += vectors[i][Y];
    zc += vectors[i][Z];
  }
  y0 = yc - zc;
  r1 = y0;
  if (r1)
    *radius = r0;
}
void Precompute_Patch_Values(BICUBIC_PATCH *Shape) {
  int i, j;
  VECTOR Control_Points[6];
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++)
      Assign_Vector(Control_Points[4 * i + j], Shape->Control_Points[i][j]);
  find_average(6, Control_Points, Shape->Bounding_Sphere_Center,
               &Shape->Bounding_Sphere_Radius);
}

at -O3 -mrvv-max-lmul=conv-dynamic -march=rv64gcv -mtune=generic-ooo lel.C

I believe the issue is an "unchecked" operand_subword in
extract_integral_bit_field that tries to build (subreg:DI (reg:V2DF ...)).
My assumption is that we need another spill, or can reroute to
extract_bit_field_1 which does it for us.  Having a look.

Reply via email to