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

            Bug ID: 125410
           Summary: hppa: ICE at -Os during RTL pass reload:
                    unrecognizable insn
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fuchsfl at gmail dot com
  Target Milestone: ---

Created attachment 64522
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64522&action=edit
Output of -freport-bug of the compilation

Reproducer: https://godbolt.org/z/6heqM6cqY
I get an ICE while cross-compiling for hppa. It happened for the package cairo
(file: src/cairo-pattern.c), from which I extracted and stripped down the
testcase below.

The ICE only occurs when the parameter -fPIE or -fPIC and -Os is added.

Testcase:

#define NULL 0
#define bool int

typedef struct {
        double x;
        double y;
} cairo_point_double_t;

typedef struct {
        cairo_point_double_t points[4][4];
} cairo_mesh_patch_t;

typedef struct {
        int dummy;
} cairo_pattern_t;

typedef struct {
        cairo_pattern_t base;

        cairo_mesh_patch_t *current_patch;
        bool has_control_point[4];
} cairo_mesh_pattern_t;

static const int mesh_control_point_i[4] = { 1, 1, 2, 2 };
static const int mesh_control_point_j[4] = { 1, 2, 2, 1 };

static void
_calc_control_point(cairo_mesh_patch_t *patch, int control_point)
{
        cairo_point_double_t *p[3][3];
        int cp_i, cp_j, i, j;

        cp_i = mesh_control_point_i[control_point];
        cp_j = mesh_control_point_j[control_point];

        for (i = 0; i < 3; i++)
                for (j = 0; j < 3; j++)
                        p[i][j] = &patch->points[cp_i ^ i][cp_j ^ j];

        p[0][0]->x = (-4 * p[1][1]->x
                      + 6 * (p[1][0]->x + p[0][1]->x)
                      - 2 * (p[1][2]->x + p[2][1]->x)
                      + 3 * (p[2][0]->x + p[0][2]->x)
                      - 1 * p[2][2]->x) * (1. / 9);

        p[0][0]->y = (-4 * p[1][1]->y
                      + 6 * (p[1][0]->y + p[0][1]->y)
                      - 2 * (p[1][2]->y + p[2][1]->y)
                      + 3 * (p[2][0]->y + p[0][2]->y)
                      - 1 * p[2][2]->y) * (1. / 9);
}

void
cairo_mesh_pattern_end_patch(cairo_pattern_t *pattern)
{
        cairo_mesh_pattern_t *mesh;
        cairo_mesh_patch_t *current_patch;
        int i;

        mesh = (cairo_mesh_pattern_t *)pattern;
        current_patch = mesh->current_patch;

        for (i = 0; i < 4; i++) {
                if (!mesh->has_control_point[i])
                        _calc_control_point(current_patch, i);
        }

        mesh->current_patch = NULL;
}


Dump:
<source>: In function 'cairo_mesh_pattern_end_patch':
<source>:69:1: error: unrecognizable insn:
   69 | }
      | ^
(insn 248 0 0 (set (reg/f:SI 310)
        (mem/f/c:SI (plus:SI (reg/f:SI 89 sfp)
                (const_int -120 [0xffffffffffffff88])) [1 p[0][0]+0 S4 A64]))
-1
     (nil))
during RTL pass: reload
<source>:69:1: internal compiler error: in extract_insn, at recog.cc:2892
0x7d9411029e3f __libc_start_main
        ???:0
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_cross_gcc_hppa_16.1.0/hppa-unknown-linux-gnu/bin/../libexec/gcc/hppa-unknown-linux-gnu/16.1.0/cc1
-quiet -iprefix
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_cross_gcc_hppa_16.1.0/hppa-unknown-linux-gnu/bin/../lib/gcc/hppa-unknown-linux-gnu/16.1.0/
-isysroot
/cefs/38/383ad2f84cbd57a52fd68bbe_consolidated/compilers_c++_cross_gcc_hppa_16.1.0/hppa-unknown-linux-gnu/bin/../hppa-unknown-linux-gnu/sysroot
<source> -quiet -dumpdir /app/ -dumpbase output.c -dumpbase-ext .c -g -Os
-fdiagnostics-color=always -fno-verbose-asm -o /app/output.s
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.
Compiler returned: 1

Reply via email to