public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2
@ 2023-01-27 16:38 zsojka at seznam dot cz
  2023-01-30  7:58 ` [Bug debug/108573] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2023-01-27 16:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108573
           Summary: [13 Regression] '-fcompare-debug' failure (length) at
                    -O2
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: compare-debug-failure
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
                CC: aoliva at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: riscv64-unknown-linux-gnu

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

Compiler output:
$ riscv64-unknown-linux-gnu-gcc -O2 -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-01-27 17:30:20.830461811 +0100
+++ a-testcase.gk.c.gkd 2023-01-27 17:30:20.887128166 +0100
@@ -95,12 +95,11 @@
      (expr_list:REG_DEAD (reg:DI 15 a5 [170])
         (expr_list:REG_DEAD (reg/v:DI 8 s0 [orig:150 s ] [150])
             (nil))))
-(insn # 0 0 (set (reg:DI 15 a5)
-        (sign_extend:DI (umod:SI (reg:SI 10 a0 [157])
-                (reg:SI 14 a4 [orig:162 g ] [162])))) "testcase.c":11:5#
{*umodsi3_extended}
+(insn # 0 0 (set (reg:SI 10 a0 [160])
+        (umod:SI (reg:SI 10 a0 [157])
+            (reg:SI 14 a4 [orig:162 g ] [162]))) "testcase.c":11:5# {umodsi3}
      (expr_list:REG_DEAD (reg:SI 14 a4 [orig:162 g ] [162])
-        (expr_list:REG_DEAD (reg:SI 10 a0 [157])
-            (nil))))
+        (nil)))
 (note # 0 0 NOTE_INSN_EPILOGUE_BEG)
 (insn/f # 0 0 (set (reg:DI 8 s0)
         (mem/c:DI (plus:DI (reg/f:DI 2 sp)
@@ -112,16 +111,19 @@
                 (const_int 24 [0x18])) [  S8 A64])) "testcase.c":14:1#
{*movdi_64bit}
      (expr_list:REG_CFA_RESTORE (reg:DI 1 ra)
         (nil)))
+(insn # 0 0 (set (reg:DI 15 a5 [orig:139 _6 ] [139])
+        (sign_extend:DI (reg:SI 10 a0 [160]))) "testcase.c":11:5#
{extendsidi2}
+     (nil))
 (insn # 0 0 (set (reg:DI 9 s1 [165])
         (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151])
             (reg:QI 15 a5 [orig:139 _6 ] [139]))) "testcase.c":12:10#
{ashrdi3}
-     (nil))
+     (expr_list:REG_DEAD (reg:QI 15 a5 [orig:139 _6 ] [139])
+        (nil)))
 (insn # 0 0 (set (reg:SI 10 a0 [167])
-        (minus:SI (reg:SI 15 a5 [160])
+        (minus:SI (reg:SI 10 a0 [160])
             (reg:SI 9 s1 [165]))) "testcase.c":12:5# {subsi3}
-     (expr_list:REG_DEAD (reg:SI 15 a5 [160])
-        (expr_list:REG_DEAD (reg:SI 9 s1 [165])
-            (nil))))
+     (expr_list:REG_DEAD (reg:SI 9 s1 [165])
+        (nil)))
 (insn/f # 0 0 (set (reg:DI 9 s1)
         (mem/c:DI (plus:DI (reg/f:DI 2 sp)
                 (const_int 8 [0x8])) [  S8 A64])) "testcase.c":14:1#
{*movdi_64bit}

$ 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-r13-5455-20230127153300-gdef6e12e348-checking-yes-rtl-df-extra-riscv64/bin/../libexec/gcc/riscv64-unknown-linux-gnu/13.0.1/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,rtl,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-r13-5455-20230127153300-gdef6e12e348-checking-yes-rtl-df-extra-riscv64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.1 20230127 (experimental) (GCC)

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
@ 2023-01-30  7:58 ` rguenth at gcc dot gnu.org
  2023-01-31 16:38 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-01-30  7:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
  2023-01-30  7:58 ` [Bug debug/108573] " rguenth at gcc dot gnu.org
@ 2023-01-31 16:38 ` jakub at gcc dot gnu.org
  2023-01-31 17:05 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-31 16:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2023-01-31

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This diverges during REE:
 Trying to eliminate extension:
-(insn 10023 10022 10027 2 (set (reg:DI 15 a5 [orig:139 _6 ] [139])
+(insn 10023 9 10027 2 (set (reg:DI 15 a5 [orig:139 _6 ] [139])
         (sign_extend:DI (reg:SI 10 a0 [160]))) "pr108573.c":11:5 116
{extendsidi2}
      (nil))
-Tentatively merged extension with definition (copy needed):
-(insn 10022 10018 10023 2 (set (reg:DI 15 a5)
-        (sign_extend:DI (umod:SI (reg:SI 10 a0 [157])
-                (reg:SI 14 a4 [orig:162 g ] [162])))) "pr108573.c":11:5 -1
-     (nil))
-deferring rescan insn with uid = 10022.
-All merges were successful.
-Eliminated the extension.
-deferring rescan insn with uid = 10055.
-deferring deletion of insn with uid = 10023.
-Elimination opportunities = 2 realized = 1
+Elimination opportunities = 2 realized = 0
 starting the processing of deferred insns
-rescanning insn with uid = 10022.
-rescanning insn with uid = 10055.
 ending the processing of deferred insns

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
  2023-01-30  7:58 ` [Bug debug/108573] " rguenth at gcc dot gnu.org
  2023-01-31 16:38 ` jakub at gcc dot gnu.org
@ 2023-01-31 17:05 ` jakub at gcc dot gnu.org
  2023-01-31 17:46 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-31 17:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, I believe this has been caused by the r7-4871-g4da41abf84cc6796aa8b
PR78437 change.
      /* On RISC machines we must make sure that changing the mode of SRC_REG
         as destination register will not affect its reaching uses, which may
         read its value in a larger mode because DEF_INSN implicitly sets it
         in word mode.  */
      poly_int64 prec
        = GET_MODE_PRECISION (GET_MODE (SET_DEST (*dest_sub_rtx)));
      if (WORD_REGISTER_OPERATIONS && known_lt (prec, BITS_PER_WORD))
        {
          struct df_link *uses = get_uses (def_insn, src_reg);
          if (!uses)
            return false;

          for (df_link *use = uses; use; use = use->next)
            if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)),
                                      GET_MODE (SET_DEST (*dest_sub_rtx))))
              return false;
        }
The problem is that without -g, there are just 2 uses:
(insn 10029 10027 10052 2 (set (reg:SI 10 a0 [167])
        (minus:SI (reg:SI 10 a0 [160])
            (reg:SI 9 s1 [165]))) "pr108573.c":12:5 12 {subsi3}
     (nil))
and
(insn 10023 9 10027 2 (set (reg:DI 15 a5 [orig:139 _6 ] [139])
        (sign_extend:DI (reg:SI 10 a0 [160]))) "pr108573.c":11:5 116
{extendsidi2}
     (nil))
but with -g there another one:
(debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10
a0 [160])
                (const_int 1 [0x1])) 0)
        (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151])
                (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1
     (nil))
Now, because it uses DImode for a0 rather than SImode like the others, without
-g
we don't return false but with -g we do.

Code generation decisions shouldn't be based on the DEBUG_INSN uses.
So, at least in this decision we should ignore debug uses, we can then do
something with the DEBUG_INSNs, reset them, adjust, whatever (I think at least
the above one clearly doesn't care about the upper bits).

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2023-01-31 17:05 ` jakub at gcc dot gnu.org
@ 2023-01-31 17:46 ` jakub at gcc dot gnu.org
  2023-02-01 11:53 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-31 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- gcc/ree.cc.jj       2023-01-02 09:32:45.327953792 +0100
+++ gcc/ree.cc  2023-01-31 18:36:31.253018233 +0100
@@ -875,7 +875,8 @@ combine_reaching_defs (ext_cand *cand, c

          for (df_link *use = uses; use; use = use->next)
            if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)),
-                                     GET_MODE (SET_DEST (*dest_sub_rtx))))
+                                     GET_MODE (SET_DEST (*dest_sub_rtx))) 
+               && !DEBUG_INSN_P (DF_REF_INSN (use->ref)))
              return false;
        }

fixes this particular -fcompare-debug failure.  Dunno though about get_uses, it
performs some checks and returns NULL if those fail (again, ignoring if the
failures are from DEBUG_INSNs or something else), plus in theory there could be
a non-NULL ref_chain of only debug uses (though hopefully we prevent that).
And there is another spot that would need the same change as above.

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2023-01-31 17:46 ` jakub at gcc dot gnu.org
@ 2023-02-01 11:53 ` cvs-commit at gcc dot gnu.org
  2023-02-01 11:54 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-01 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

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

commit r13-5625-ge4473d7cf871c8ddf8f22d105c5af6375ebe37bf
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 1 12:52:52 2023 +0100

    ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573]

    The PR78437 r7-4871 changes made combine_reaching_defs punt on
    WORD_REGISTER_OPERATIONS targets if a setter of smaller than word
    register has wider uses.  This unfortunately breaks -fcompare-debug,
    because if such a use appears only in DEBUG_INSN(s), while all other
    uses aren't wider than the setter, we can REE optimize it without -g
    and not with -g.

    Such decisions shouldn't be based on debug instructions.  We could try
    to reset them or adjust in some other way after we decide to perform the
    change, but at least on the testcase which used to fail on riscv64-linux
    the
    (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI
10 a0 [160])
                    (const_int 1 [0x1])) 0)
            (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151])
                    (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1
         (nil))
    clearly doesn't care about the upper bits and I have hard time imaging how
    could one end up with DEBUG_INSN which actually cares about those upper
    bits.

    So, the following patch just ignores uses on DEBUG_INSNs in this case,
    if we run into something where we'd need to do something further later on,
    let's deal with it when we have a testcase for it.

    2023-02-01  Jakub Jelinek  <jakub@redhat.com>

            PR debug/108573
            * ree.cc (combine_reaching_defs): Don't return false for
paradoxical
            subregs in DEBUG_INSNs.

            * gcc.dg/pr108573.c: New test.

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2023-02-01 11:53 ` cvs-commit at gcc dot gnu.org
@ 2023-02-01 11:54 ` jakub at gcc dot gnu.org
  2023-02-10 17:46 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-01 11:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2023-02-01 11:54 ` jakub at gcc dot gnu.org
@ 2023-02-10 17:46 ` cvs-commit at gcc dot gnu.org
  2023-05-02 20:14 ` cvs-commit at gcc dot gnu.org
  2023-05-03 15:21 ` cvs-commit at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:7bd8b65bd5d51a33f31ec39dfb435b84e36260e9

commit r12-9149-g7bd8b65bd5d51a33f31ec39dfb435b84e36260e9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 1 12:52:52 2023 +0100

    ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573]

    The PR78437 r7-4871 changes made combine_reaching_defs punt on
    WORD_REGISTER_OPERATIONS targets if a setter of smaller than word
    register has wider uses.  This unfortunately breaks -fcompare-debug,
    because if such a use appears only in DEBUG_INSN(s), while all other
    uses aren't wider than the setter, we can REE optimize it without -g
    and not with -g.

    Such decisions shouldn't be based on debug instructions.  We could try
    to reset them or adjust in some other way after we decide to perform the
    change, but at least on the testcase which used to fail on riscv64-linux
    the
    (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI
10 a0 [160])
                    (const_int 1 [0x1])) 0)
            (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151])
                    (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1
         (nil))
    clearly doesn't care about the upper bits and I have hard time imaging how
    could one end up with DEBUG_INSN which actually cares about those upper
    bits.

    So, the following patch just ignores uses on DEBUG_INSNs in this case,
    if we run into something where we'd need to do something further later on,
    let's deal with it when we have a testcase for it.

    2023-02-01  Jakub Jelinek  <jakub@redhat.com>

            PR debug/108573
            * ree.cc (combine_reaching_defs): Don't return false for
paradoxical
            subregs in DEBUG_INSNs.

            * gcc.dg/pr108573.c: New test.

    (cherry picked from commit e4473d7cf871c8ddf8f22d105c5af6375ebe37bf)

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2023-02-10 17:46 ` cvs-commit at gcc dot gnu.org
@ 2023-05-02 20:14 ` cvs-commit at gcc dot gnu.org
  2023-05-03 15:21 ` cvs-commit at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-02 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r11-10706-gc8aee6e44b5829ce3baafd358d2ff9f30ee7e88b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 1 12:52:52 2023 +0100

    ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573]

    The PR78437 r7-4871 changes made combine_reaching_defs punt on
    WORD_REGISTER_OPERATIONS targets if a setter of smaller than word
    register has wider uses.  This unfortunately breaks -fcompare-debug,
    because if such a use appears only in DEBUG_INSN(s), while all other
    uses aren't wider than the setter, we can REE optimize it without -g
    and not with -g.

    Such decisions shouldn't be based on debug instructions.  We could try
    to reset them or adjust in some other way after we decide to perform the
    change, but at least on the testcase which used to fail on riscv64-linux
    the
    (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI
10 a0 [160])
                    (const_int 1 [0x1])) 0)
            (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151])
                    (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1
         (nil))
    clearly doesn't care about the upper bits and I have hard time imaging how
    could one end up with DEBUG_INSN which actually cares about those upper
    bits.

    So, the following patch just ignores uses on DEBUG_INSNs in this case,
    if we run into something where we'd need to do something further later on,
    let's deal with it when we have a testcase for it.

    2023-02-01  Jakub Jelinek  <jakub@redhat.com>

            PR debug/108573
            * ree.c (combine_reaching_defs): Don't return false for paradoxical
            subregs in DEBUG_INSNs.

            * gcc.dg/pr108573.c: New test.

    (cherry picked from commit e4473d7cf871c8ddf8f22d105c5af6375ebe37bf)

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

* [Bug debug/108573] [13 Regression] '-fcompare-debug' failure (length) at -O2
  2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2023-05-02 20:14 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03 15:21 ` cvs-commit at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-03 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

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

commit r10-11361-gd868dd64ccd176cbd2829aa6175b40323f937b20
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 1 12:52:52 2023 +0100

    ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573]

    The PR78437 r7-4871 changes made combine_reaching_defs punt on
    WORD_REGISTER_OPERATIONS targets if a setter of smaller than word
    register has wider uses.  This unfortunately breaks -fcompare-debug,
    because if such a use appears only in DEBUG_INSN(s), while all other
    uses aren't wider than the setter, we can REE optimize it without -g
    and not with -g.

    Such decisions shouldn't be based on debug instructions.  We could try
    to reset them or adjust in some other way after we decide to perform the
    change, but at least on the testcase which used to fail on riscv64-linux
    the
    (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI
10 a0 [160])
                    (const_int 1 [0x1])) 0)
            (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151])
                    (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1
         (nil))
    clearly doesn't care about the upper bits and I have hard time imaging how
    could one end up with DEBUG_INSN which actually cares about those upper
    bits.

    So, the following patch just ignores uses on DEBUG_INSNs in this case,
    if we run into something where we'd need to do something further later on,
    let's deal with it when we have a testcase for it.

    2023-02-01  Jakub Jelinek  <jakub@redhat.com>

            PR debug/108573
            * ree.c (combine_reaching_defs): Don't return false for paradoxical
            subregs in DEBUG_INSNs.

            * gcc.dg/pr108573.c: New test.

    (cherry picked from commit e4473d7cf871c8ddf8f22d105c5af6375ebe37bf)

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

end of thread, other threads:[~2023-05-03 15:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 16:38 [Bug debug/108573] New: [13 Regression] '-fcompare-debug' failure (length) at -O2 zsojka at seznam dot cz
2023-01-30  7:58 ` [Bug debug/108573] " rguenth at gcc dot gnu.org
2023-01-31 16:38 ` jakub at gcc dot gnu.org
2023-01-31 17:05 ` jakub at gcc dot gnu.org
2023-01-31 17:46 ` jakub at gcc dot gnu.org
2023-02-01 11:53 ` cvs-commit at gcc dot gnu.org
2023-02-01 11:54 ` jakub at gcc dot gnu.org
2023-02-10 17:46 ` cvs-commit at gcc dot gnu.org
2023-05-02 20:14 ` cvs-commit at gcc dot gnu.org
2023-05-03 15:21 ` cvs-commit 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).