public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os
@ 2024-04-26  7:00 xry111 at gcc dot gnu.org
  2024-04-26  7:05 ` [Bug target/114861] LoongArch: ICE building " xry111 at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-26  7:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114861
           Summary: LoongArch: Fail to build the kernel with -Os
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at gcc dot gnu.org
  Target Milestone: ---

drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c: In function ‘gfx_v6_0_hw_init’:
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c:3144:1: error: could not split insn
(insn:TI 1764 67 1745 (set (mem/c:DI (reg/f:DI 3 $r3) [707 %sfp+-80 S8 A64])
        (and:DI (reg/v:DI 28 $r28 [orig:422 raster_config ] [422])
            (const_int -50331649 [0xfffffffffcffffff])))
"drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c":1386:21 111 {*bstrins_di_for_mask}
     (nil))
during RTL pass: final
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c:3144:1: internal compiler error: in
final_scan_insn_1, at final.cc:2807
0x6fdffe _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        ../../gcc/gcc/rtl-error.cc:108
0x68dc4b final_scan_insn_1
        ../../gcc/gcc/final.cc:2807
0xb38398 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
        ../../gcc/gcc/final.cc:2886
0xb3858f final_1
        ../../gcc/gcc/final.cc:1977
0xb39096 rest_of_handle_final
        ../../gcc/gcc/final.cc:4239
0xb39096 execute
        ../../gcc/gcc/final.cc:4317
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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
@ 2024-04-26  7:05 ` xry111 at gcc dot gnu.org
  2024-04-26  7:37 ` xry111 at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-26  7:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Created attachment 58044
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58044&action=edit
Preprocessed source

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
  2024-04-26  7:05 ` [Bug target/114861] LoongArch: ICE building " xry111 at gcc dot gnu.org
@ 2024-04-26  7:37 ` xry111 at gcc dot gnu.org
  2024-04-26  7:41 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-26  7:37 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
It seems we are missing a constraint for bstrins_<mode>_for_mask:

diff --git a/gcc/config/loongarch/loongarch.md
b/gcc/config/loongarch/loongarch.md
index a316c8fb820..0c86f27e768 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -1543,9 +1543,9 @@ (define_insn "and<mode>3_extended"
    (set_attr "mode" "<MODE>")])

 (define_insn_and_split "*bstrins_<mode>_for_mask"
-  [(set (match_operand:GPR 0 "register_operand")
-       (and:GPR (match_operand:GPR 1 "register_operand")
-                (match_operand:GPR 2 "ins_zero_bitmask_operand")))]
+  [(set (match_operand:GPR 0 "register_operand" "=r,r")
+       (and:GPR (match_operand:GPR 1 "register_operand" "r,m")
+                (match_operand:GPR 2 "ins_zero_bitmask_operand" "i,i")))]
   ""
   "#"
   ""

This fixes the ICE on the attached test case.

I still need to review other splits and make a reduced test case.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
  2024-04-26  7:05 ` [Bug target/114861] LoongArch: ICE building " xry111 at gcc dot gnu.org
  2024-04-26  7:37 ` xry111 at gcc dot gnu.org
@ 2024-04-26  7:41 ` jakub at gcc dot gnu.org
  2024-04-26  7:51 ` xry111 at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-04-26  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
m for register_operand???

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-04-26  7:41 ` jakub at gcc dot gnu.org
@ 2024-04-26  7:51 ` xry111 at gcc dot gnu.org
  2024-04-26  9:29 ` xry111 at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-26  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> m for register_operand???

Hmm indeed, the m alternative should be removed.  I must had been sleeping when
I typed it...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-04-26  7:51 ` xry111 at gcc dot gnu.org
@ 2024-04-26  9:29 ` xry111 at gcc dot gnu.org
  2024-04-26 14:27 ` [Bug target/114861] [14/15 Regression] " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-26  9:29 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-reduction             |ice-on-valid-code

--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Reduced test case:

long evcn, attr_collapse_range_vbo, attr_collapse_range_bytes;
unsigned short flags;
int attr_collapse_range_ni_0_0;
int *attr_collapse_range_mi;
unsigned attr_collapse_range_svcn, attr_collapse_range_vcn1;
void ni_insert_nonresident(unsigned, unsigned short, int **);
int mi_pack_runs(int);
int attr_collapse_range(void) {
  _Bool __trans_tmp_1;
  int run = attr_collapse_range_ni_0_0;
  unsigned evcn1, vcn, end;
  short a_flags = flags;
  __trans_tmp_1 = flags & (32768 | 1);
  if (__trans_tmp_1)
    return 2;
  vcn = attr_collapse_range_vbo;
  end = attr_collapse_range_bytes;
  evcn1 = evcn;
  for (;;)
    if (attr_collapse_range_svcn >= end) {
      unsigned eat, next_svcn = mi_pack_runs(42);
      attr_collapse_range_vcn1 = (vcn ? vcn: attr_collapse_range_svcn);
      eat = (0 < end) - attr_collapse_range_vcn1;
      mi_pack_runs(run - eat);
      if (next_svcn + eat)
        ni_insert_nonresident(evcn1 - eat - next_svcn, a_flags,
                              &attr_collapse_range_mi);
    } else
      return 42;
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] [14/15 Regression] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-04-26  9:29 ` xry111 at gcc dot gnu.org
@ 2024-04-26 14:27 ` rguenth at gcc dot gnu.org
  2024-04-26 15:57 ` xry111 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-26 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] [14/15 Regression] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-04-26 14:27 ` [Bug target/114861] [14/15 Regression] " rguenth at gcc dot gnu.org
@ 2024-04-26 15:57 ` xry111 at gcc dot gnu.org
  2024-04-27  4:00 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-26 15:57 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-04-26
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Keywords|                            |patch
           Assignee|unassigned at gcc dot gnu.org      |xry111 at gcc dot gnu.org

--- Comment #6 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
https://gcc.gnu.org/pipermail/gcc-patches/2024-April/650077.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] [14/15 Regression] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-04-26 15:57 ` xry111 at gcc dot gnu.org
@ 2024-04-27  4:00 ` cvs-commit at gcc dot gnu.org
  2024-04-27  4:02 ` cvs-commit at gcc dot gnu.org
  2024-04-27  4:03 ` xry111 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-27  4:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:

https://gcc.gnu.org/g:140124ad54eef88ca87909f63aedc8aaeacefc65

commit r15-11-g140124ad54eef88ca87909f63aedc8aaeacefc65
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Fri Apr 26 15:59:11 2024 +0800

    LoongArch: Add constraints for bit string operation define_insn_and_split's
[PR114861]

    Without the constrants, the compiler attempts to use a stack slot as the
    target, causing an ICE building the kernel with -Os:

        drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c:3144:1:
        error: could not split insn
        (insn:TI 1764 67 1745
          (set (mem/c:DI (reg/f:DI 3 $r3) [707 %sfp+-80 S8 A64])
               (and:DI (reg/v:DI 28 $r28 [orig:422 raster_config ] [422])
                       (const_int -50331649 [0xfffffffffcffffff])))
          "drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c":1386:21 111
          {*bstrins_di_for_mask}
          (nil))

    Add these constrants to fix the issue.

    gcc/ChangeLog:

            PR target/114861
            * config/loongarch/loongarch.md (bstrins_<mode>_for_mask): Add
            constraints for operands.
            (bstrins_<mode>_for_ior_mask): Likewise.

    gcc/testsuite/ChangeLog:

            PR target/114861
            * gcc.target/loongarch/pr114861.c: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] [14/15 Regression] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2024-04-27  4:00 ` cvs-commit at gcc dot gnu.org
@ 2024-04-27  4:02 ` cvs-commit at gcc dot gnu.org
  2024-04-27  4:03 ` xry111 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-27  4:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:

https://gcc.gnu.org/g:3e04b6f6ba568e6183e8aa8223d4156234503843

commit r14-10142-g3e04b6f6ba568e6183e8aa8223d4156234503843
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Fri Apr 26 15:59:11 2024 +0800

    LoongArch: Add constraints for bit string operation define_insn_and_split's
[PR114861]

    Without the constrants, the compiler attempts to use a stack slot as the
    target, causing an ICE building the kernel with -Os:

        drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c:3144:1:
        error: could not split insn
        (insn:TI 1764 67 1745
          (set (mem/c:DI (reg/f:DI 3 $r3) [707 %sfp+-80 S8 A64])
               (and:DI (reg/v:DI 28 $r28 [orig:422 raster_config ] [422])
                       (const_int -50331649 [0xfffffffffcffffff])))
          "drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c":1386:21 111
          {*bstrins_di_for_mask}
          (nil))

    Add these constrants to fix the issue.

    gcc/ChangeLog:

            PR target/114861
            * config/loongarch/loongarch.md (bstrins_<mode>_for_mask): Add
            constraints for operands.
            (bstrins_<mode>_for_ior_mask): Likewise.

    gcc/testsuite/ChangeLog:

            PR target/114861
            * gcc.target/loongarch/pr114861.c: New test.

    (cherry picked from commit 140124ad54eef88ca87909f63aedc8aaeacefc65)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/114861] [14/15 Regression] LoongArch: ICE building the kernel with -Os
  2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2024-04-27  4:02 ` cvs-commit at gcc dot gnu.org
@ 2024-04-27  4:03 ` xry111 at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-04-27  4:03 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Fixed for 15 and 14.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-04-27  4:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-26  7:00 [Bug target/114861] New: LoongArch: Fail to build the kernel with -Os xry111 at gcc dot gnu.org
2024-04-26  7:05 ` [Bug target/114861] LoongArch: ICE building " xry111 at gcc dot gnu.org
2024-04-26  7:37 ` xry111 at gcc dot gnu.org
2024-04-26  7:41 ` jakub at gcc dot gnu.org
2024-04-26  7:51 ` xry111 at gcc dot gnu.org
2024-04-26  9:29 ` xry111 at gcc dot gnu.org
2024-04-26 14:27 ` [Bug target/114861] [14/15 Regression] " rguenth at gcc dot gnu.org
2024-04-26 15:57 ` xry111 at gcc dot gnu.org
2024-04-27  4:00 ` cvs-commit at gcc dot gnu.org
2024-04-27  4:02 ` cvs-commit at gcc dot gnu.org
2024-04-27  4:03 ` xry111 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).