public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
@ 2023-09-10 11:15 zsojka at seznam dot cz
  2023-09-12 12:20 ` [Bug target/111362] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2023-09-10 11:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111362
           Summary: [14 Regression] '-fcompare-debug' failure (length)
                    with -O -fno-tree-ch
                    --param=max-completely-peel-times=0 -march=rv64iv
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: compare-debug-failure
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: riscv64-unknown-linux-gnu

Created attachment 55871
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55871&action=edit
reduced testcase

Compiler output:
$ riscv64-unknown-linux-gnu-gcc -O -fno-tree-ch
--param=max-completely-peel-times=0 -march=rv64iv -fcompare-debug testcase.c
-save-temps
riscv64-unknown-linux-gnu-gcc: error: testcase.c: '-fcompare-debug' failure
(length)

$ diff -u *gkd
--- a-testcase.c.gkd    2023-09-10 13:14:46.728418677 +0200
+++ a-testcase.gk.c.gkd 2023-09-10 13:14:46.781751718 +0200
@@ -34,17 +34,7 @@
                         (const_int 8 [0x8])) [  S8 A64])
                 (reg:DI 9 s1))
             (nil))))
-(insn/f # 0 0 (set (mem/c:DI (reg/f:DI 2 sp) [  S8 A64])
-        (reg:DI 18 s2)) "testcase.c":2:11# {*movdi_64bit}
-     (expr_list:REG_DEAD (reg:DI 18 s2)
-        (expr_list:REG_FRAME_RELATED_EXPR (set/f (mem/c:DI (reg/f:DI 2 sp) [ 
S8 A64])
-                (reg:DI 18 s2))
-            (nil))))
 (note # 0 0 NOTE_INSN_PROLOGUE_END)
-(insn # 0 0 (set (reg:SI 18 s2 [139])
-        (reg:SI 69 frm))# {frrmsi}
-     (expr_list:REG_DEAD (reg:SI 69 frm)
-        (nil)))
 (note # 0 0 NOTE_INSN_FUNCTION_BEG)
 (insn # 0 0 (set (reg:DI 8 s0 [orig:134 ivtmp_6 ] [134])
         (const_int 2 [0x2])) "testcase.c":3:3# {*movdi_64bit}
@@ -85,10 +75,6 @@
                 (const_int 8 [0x8])) [  S8 A64])) "testcase.c":5:1#
{*movdi_64bit}
      (expr_list:REG_CFA_RESTORE (reg:DI 9 s1)
         (nil)))
-(insn/f # 0 0 (set (reg:DI 18 s2)
-        (mem/c:DI (reg/f:DI 2 sp) [  S8 A64])) "testcase.c":5:1#
{*movdi_64bit}
-     (expr_list:REG_CFA_RESTORE (reg:DI 18 s2)
-        (nil)))
 (insn # 0 0 (set (mem:BLK (scratch) [  A8])
         (unspec:BLK [
                 (reg/f:DI 2 sp)
@@ -118,12 +104,6 @@
             (symbol_ref/f:DI ("*.LC0") [flags 0x82]  <var_decl # *.LC0>)))
"testcase.c":4:5# {*lowdi}
      (expr_list:REG_EQUAL (symbol_ref/f:DI ("*.LC0") [flags 0x82]  <var_decl #
*.LC0>)
         (nil)))
-(insn # 0 0 (set (reg:SI 69 frm)
-        (unspec_volatile:SI [
-                (reg:SI 18 s2 [139])
-            ] UNSPECV_FRM_RESTORE_EXIT)) "testcase.c":4:5#
{fsrmsi_restore_volatile}
-     (expr_list:REG_UNUSED (reg:SI 69 frm)
-        (nil)))
 (call_insn # 0 0 (parallel [
             (set (reg:DI 10 a0)
                 (call (mem:SI (symbol_ref:DI ("printf") [flags 0x41] 
<function_decl # __builtin_printf>) [ __builtin_printf S4 A32])

$ riscv64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-riscv64/bin/riscv64-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-3825-20230910101237-g0d50facd937-checking-yes-df-extra-riscv64/bin/../libexec/gcc/riscv64-unknown-linux-gnu/14.0.0/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,df,extra
--with-cloog --with-ppl --with-isl --with-isa-spec=2.2
--with-sysroot=/usr/riscv64-unknown-linux-gnu --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=riscv64-unknown-linux-gnu
--with-ld=/usr/bin/riscv64-unknown-linux-gnu-ld
--with-as=/usr/bin/riscv64-unknown-linux-gnu-as --disable-multilib
--disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-3825-20230910101237-g0d50facd937-checking-yes-df-extra-riscv64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20230910 (experimental) (GCC)

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

* [Bug target/111362] [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
  2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
@ 2023-09-12 12:20 ` rguenth at gcc dot gnu.org
  2023-09-13  6:19 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-09-12 12:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug target/111362] [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
  2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
  2023-09-12 12:20 ` [Bug target/111362] " rguenth at gcc dot gnu.org
@ 2023-09-13  6:19 ` cvs-commit at gcc dot gnu.org
  2023-09-14 15:10 ` zsojka at seznam dot cz
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-13  6:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pan Li <panli@gcc.gnu.org>:

https://gcc.gnu.org/g:feb23a37e6142016c3463aa3be3e900d45bc3ea5

commit r14-3915-gfeb23a37e6142016c3463aa3be3e900d45bc3ea5
Author: Pan Li <pan2.li@intel.com>
Date:   Wed Sep 13 11:34:42 2023 +0800

    RISC-V: Bugfix PR111362 for incorrect frm emit

    When the mode switching from NONE to CALL, we will restore the
    frm but lack some check if we have static frm insn in cfun.

    This patch would like to fix this by adding static frm insn check.

            PR target/111362

    gcc/ChangeLog:

            * config/riscv/riscv.cc (riscv_emit_frm_mode_set): Bugfix.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/base/no-honor-frm-1.c: New test.

    Signed-off-by: Pan Li <pan2.li@intel.com>

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

* [Bug target/111362] [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
  2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
  2023-09-12 12:20 ` [Bug target/111362] " rguenth at gcc dot gnu.org
  2023-09-13  6:19 ` cvs-commit at gcc dot gnu.org
@ 2023-09-14 15:10 ` zsojka at seznam dot cz
  2024-03-09 17:46 ` law at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2023-09-14 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zdenek Sojka <zsojka at seznam dot cz> ---
Thank you the fix; the testcase is still failing with a bit different flags
though:

Adding -fno-dce -fschedule-insns:

$ riscv64-unknown-linux-gnu-gcc -O -fno-tree-ch
--param=max-completely-peel-times=0 -march=rv64iv -fcompare-debug -fno-dce
-fschedule-insns testcase.c -save-temps
riscv64-unknown-linux-gnu-gcc: error: testcase.c: '-fcompare-debug' failure

$ diff -u *gkd
--- a-testcase.c.gkd    2023-09-14 17:09:28.262936149 +0200
+++ a-testcase.gk.c.gkd 2023-09-14 17:09:28.342935710 +0200
@@ -51,14 +51,6 @@
         (sign_extend:DI (plus:SI (reg:SI 8 s0 [orig:134 ivtmp_6 ] [134])
                 (const_int -1 [0xffffffffffffffff])))) "testcase.c":3:26
discrim 1# {addsi3_extended}
      (nil))
-(insn # 0 0 (set (reg:DI 11 a1)
-        (const_int 0 [0])) "testcase.c":4:5# {*movdi_64bit}
-     (nil))
-(insn # 0 0 (set (reg:DI 10 a0)
-        (lo_sum:DI (reg/f:DI 9 s1 [138])
-            (symbol_ref/f:DI ("*.LC0") [flags 0x82]  <var_decl # *.LC0>)))
"testcase.c":4:5# {*lowdi}
-     (expr_list:REG_EQUAL (symbol_ref/f:DI ("*.LC0") [flags 0x82]  <var_decl #
*.LC0>)
-        (nil)))
 (jump_insn # 0 0 (set (pc)
         (if_then_else (ne (reg:DI 8 s0 [orig:134 ivtmp_6 ] [134])
                 (const_int 0 [0]))
@@ -104,6 +96,14 @@
 (barrier # 0 0)
 (code_label # 0 0 3 (nil) [1 uses])
 (note # 0 0 [bb 5] NOTE_INSN_BASIC_BLOCK)
+(insn # 0 0 (set (reg:DI 11 a1)
+        (const_int 0 [0])) "testcase.c":4:5# {*movdi_64bit}
+     (nil))
+(insn # 0 0 (set (reg:DI 10 a0)
+        (lo_sum:DI (reg/f:DI 9 s1 [138])
+            (symbol_ref/f:DI ("*.LC0") [flags 0x82]  <var_decl # *.LC0>)))
"testcase.c":4:5# {*lowdi}
+     (expr_list:REG_EQUAL (symbol_ref/f:DI ("*.LC0") [flags 0x82]  <var_decl #
*.LC0>)
+        (nil)))
 (call_insn # 0 0 (parallel [
             (set (reg:DI 10 a0)
                 (call (mem:SI (symbol_ref:DI ("printf") [flags 0x41] 
<function_decl # __builtin_printf>) [ __builtin_printf S4 A32])

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

* [Bug target/111362] [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
  2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-09-14 15:10 ` zsojka at seznam dot cz
@ 2024-03-09 17:46 ` law at gcc dot gnu.org
  2024-03-09 23:45 ` law at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-09 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-03-09

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

* [Bug target/111362] [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
  2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-03-09 17:46 ` law at gcc dot gnu.org
@ 2024-03-09 23:45 ` law at gcc dot gnu.org
  2024-03-10  2:39 ` cvs-commit at gcc dot gnu.org
  2024-03-10  2:40 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-09 23:45 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |law at gcc dot gnu.org

--- Comment #3 from Jeffrey A. Law <law at gcc dot gnu.org> ---

Looks like a minor bug in the generic mode-switching code to me.  Testing a
fix...

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

* [Bug target/111362] [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
  2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-03-09 23:45 ` law at gcc dot gnu.org
@ 2024-03-10  2:39 ` cvs-commit at gcc dot gnu.org
  2024-03-10  2:40 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-10  2:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jeff Law <law@gcc.gnu.org>:

https://gcc.gnu.org/g:50531b6d400945793a1d549e6ee941d989319d42

commit r14-9415-g50531b6d400945793a1d549e6ee941d989319d42
Author: jlaw <jeffreyalaw@gmail.com>
Date:   Sat Mar 9 19:27:32 2024 -0700

    [committed] [PR target/111362] Fix compare-debug issue with mode switching

    The issue here is the code we emit for mode-switching can change when -g is
    added to the command line.  This is caused by processing debug notes
occurring
    after a call which is the last real statement in a basic block.

    Without -g the CALL_INSN is literally the last insn in the block and the
loop
    exits.  If mode switching after the call is needed, it'll be handled as we
    process outgoing edges.

    With -g the loop iterates again and in the processing of the node the
backend
    signals that a mode switch is necessary.

    I pondered fixing this in the target, but the better fix is to ignore the
debug
    notes in the insn stream.

    I did a cursory review of some of the other compare-debug failures, but did
not
    immediately see others which would likely be fixed by this change.  Sigh.

    Anyway, bootstrapped and regression tested on x86.  Regression tested on
rv64
    as well.

            PR target/111362
    gcc/
            * mode-switching.cc (optimize_mode_switching): Only process
            NONDEBUG insns.

    gcc/testsuite

            * gcc.target/riscv/compare-debug-1.c: New test.
            * gcc.target/riscv/compare-debug-2.c: New test.

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

* [Bug target/111362] [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv
  2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2024-03-10  2:39 ` cvs-commit at gcc dot gnu.org
@ 2024-03-10  2:40 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-10  2:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

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

--- Comment #5 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Fixed on the trunk.

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

end of thread, other threads:[~2024-03-10  2:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-10 11:15 [Bug target/111362] New: [14 Regression] '-fcompare-debug' failure (length) with -O -fno-tree-ch --param=max-completely-peel-times=0 -march=rv64iv zsojka at seznam dot cz
2023-09-12 12:20 ` [Bug target/111362] " rguenth at gcc dot gnu.org
2023-09-13  6:19 ` cvs-commit at gcc dot gnu.org
2023-09-14 15:10 ` zsojka at seznam dot cz
2024-03-09 17:46 ` law at gcc dot gnu.org
2024-03-09 23:45 ` law at gcc dot gnu.org
2024-03-10  2:39 ` cvs-commit at gcc dot gnu.org
2024-03-10  2:40 ` law 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).