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

            Bug ID: 128792
           Summary: [powerpc64le] ICE in operand_subword_force passing
                    struct { _Complex float } when only one FPR is left
                    (emit_push_insn on a CONCAT)
           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: lzy20000419 at outlook dot com
  Target Milestone: ---

Fails with trunk (gcc 17.0.0 20261116) and with 6.3.0, 11.2.0, 12.5.0, 13.4.0,
14.3.0, 15.2.0 and 16.1.0; the power64le AT12.0 (gcc 8) and AT13.0 (gcc 9)
compilers ICE too. No working version was found, so this is not a regression.
Target: powerpc64le-linux-gnu (ELFv2).

    struct CF { _Complex float c; };

    void g (double, double, double, double, double, double, double, double,
            double, double, double, double, struct CF);

    void
    f (struct CF l)
    {
      g (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, l);
    }

    powerpc64le-linux-gnu-gcc -O1 -c t.c

    t.c: In function 'f':
    t.c:9:3: internal compiler error: in operand_subword_force, at
emit-rtl.cc:1854

Expected: successful compilation. -O1, -O2, -O3 and -Os ICE; -O0 compiles. When
the argument comes from a call (g (..., h ())), -O0 ICEs too.

Godbolt (trunk): https://godbolt.org/z/5nY9PTs7G

The 12 doubles use f1-f12, so only f13 is left. rs6000_arg_partial_bytes
returns 4: the real part goes in f13 and the imaginary part in the parameter
save area. struct CF has SCmode and is held in a (concat:SC (reg:SF) (reg:SF)).
emit_push_insn takes the partial branch and calls operand_subword_force (x, i,
SCmode) for DImode words. simplify_subreg cannot take an 8-byte word from a
CONCAT of 4-byte parts. force_reg (SCmode, x) creates another CONCAT, so the
assert fires. struct { _Complex double c; } works because its parts are
word-sized.

Possible fix: in emit_push_insn, spill a CONCAT whose parts are narrower than a
word to a stack temporary before calling operand_subword_force.

Disclaimer: This test case was generated by a fuzzer, and the report was
written with LLM assistance.

Reply via email to