public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv
@ 2021-12-22 17:08 asolokha at gmx dot com
2021-12-22 21:18 ` [Bug middle-end/103808] " pinskia at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: asolokha at gmx dot com @ 2021-12-22 17:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
Bug ID: 103808
Summary: [12 Regression] '-fcompare-debug' failure (length) w/
-O2 -ftrapv
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: asolokha at gmx dot com
Target Milestone: ---
Target: x86_64-unknown-linux-gnu
gcc 12.0.0 20211219 snapshot (g:fcbf94a5be9e0c1ecad92da773a6632b86b7f70a) fails
-fcompare-debug check when compiling the following testcase w/ -O2 -ftrapv:
void
foo (__int128 x, int y)
{
for (;;)
{
__int128 a, b;
x |= !!y;
a = x + 1;
b = y ? ++y : ++x;
y = a < b;
if (x >> 2)
y *= 2;
if (y == b)
__builtin_unreachable ();
}
}
% x86_64-unknown-linux-gnu-gcc-12.0.0 -O2 -fcompare-debug -ftrapv -c ddz9adk2.c
x86_64-unknown-linux-gnu-gcc-12.0.0: error: ddz9adk2.c: '-fcompare-debug'
failure (length)
--- ddz9adk2.c.gkd 2021-12-23 00:04:28.297518259 +0700
+++ ddz9adk2.gk.c.gkd 2021-12-23 00:04:28.387512439 +0700
@@ -6,11 +6,11 @@
(note # 0 0 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note # 0 0 NOTE_INSN_DELETED)
(note # 0 0 NOTE_INSN_DELETED)
-(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [ S8 A8])
+(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp [ x+8 ])) [ S8
A8])
(reg:DI 42 r14)) "ddz9adk2.c":3:1# {*pushdi2_rex64}
(expr_list:REG_DEAD (reg:DI 42 r14)
(nil)))
-(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [ S8 A8])
+(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp [ x+8 ])) [ S8
A8])
(reg:DI 41 r13)) "ddz9adk2.c":3:1# {*pushdi2_rex64}
(expr_list:REG_DEAD (reg:DI 41 r13)
(nil)))
@@ -18,7 +18,7 @@
(reg:DI 4 si [123])) "ddz9adk2.c":3:1# {*movdi_internal}
(expr_list:REG_DEAD (reg:DI 4 si [123])
(nil)))
-(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [ S8 A8])
+(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp [ x+8 ])) [ S8
A8])
(reg:DI 40 r12)) "ddz9adk2.c":3:1# {*pushdi2_rex64}
(expr_list:REG_DEAD (reg:DI 40 r12)
(nil)))
@@ -26,11 +26,11 @@
(reg:DI 5 di [122])) "ddz9adk2.c":3:1# {*movdi_internal}
(expr_list:REG_DEAD (reg:DI 5 di [122])
(nil)))
-(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [ S8 A8])
+(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp [ x+8 ])) [ S8
A8])
(reg:DI 6 bp)) "ddz9adk2.c":3:1# {*pushdi2_rex64}
(expr_list:REG_DEAD (reg:DI 6 bp)
(nil)))
-(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [ S8 A8])
+(insn/f:TI # 0 0 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp [ x+8 ])) [ S8
A8])
(reg:DI 3 bx)) "ddz9adk2.c":3:1# {*pushdi2_rex64}
(expr_list:REG_DEAD (reg:DI 3 bx)
(nil)))
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
@ 2021-12-22 21:18 ` pinskia at gcc dot gnu.org
2021-12-22 23:34 ` [Bug target/103808] " pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-22 21:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|debug |middle-end
Target Milestone|--- |12.0
Keywords| |ice-on-valid-code,
| |wrong-debug
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
2021-12-22 21:18 ` [Bug middle-end/103808] " pinskia at gcc dot gnu.org
@ 2021-12-22 23:34 ` pinskia at gcc dot gnu.org
2021-12-22 23:36 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-22 23:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|middle-end |target
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
t233.gk.c.327r.mach is where the difference shows up so the bug is inside
ix86_reorg somewhere.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
2021-12-22 21:18 ` [Bug middle-end/103808] " pinskia at gcc dot gnu.org
2021-12-22 23:34 ` [Bug target/103808] " pinskia at gcc dot gnu.org
@ 2021-12-22 23:36 ` pinskia at gcc dot gnu.org
2021-12-22 23:57 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-22 23:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |needs-bisection
Last reconfirmed| |2021-12-22
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
` (2 preceding siblings ...)
2021-12-22 23:36 ` pinskia at gcc dot gnu.org
@ 2021-12-22 23:57 ` pinskia at gcc dot gnu.org
2021-12-23 8:32 ` [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv since r12-5944-ga7acb6dca941db2b marxin at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-22 23:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is a latent bug exposed by my match.pd patch (r12-5392).
In GCC 11.2.0 we had:
y_18 = iftmp.0_10 > a_14 ? 2 : 0;
While on the trunk we have:
y_18 = prephitmp_29 * 2;
But doing this:
void
foo (__int128 x, int y)
{
for (;;)
{
__int128 a, b;
x |= !!y;
a = x + 1;
b = y ? ++y : ++x;
y = a < b;
asm("":"+r"(y));
if (x >> 2)
y *= 2;
if (y == b)
__builtin_unreachable ();
}
}
Which causes the IR to be the same out of 11 and 12, does not produce compare
debug in 11 but does in 12.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv since r12-5944-ga7acb6dca941db2b
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
` (3 preceding siblings ...)
2021-12-22 23:57 ` pinskia at gcc dot gnu.org
@ 2021-12-23 8:32 ` marxin at gcc dot gnu.org
2021-12-28 18:37 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-12-23 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
Summary|[12 Regression] |[12 Regression]
|'-fcompare-debug' failure |'-fcompare-debug' failure
|(length) w/ -O2 -ftrapv |(length) w/ -O2 -ftrapv
| |since
| |r12-5944-ga7acb6dca941db2b
CC| |marxin at gcc dot gnu.org,
| |vmakarov at gcc dot gnu.org
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Example from #c3 started to fail with r12-5944-ga7acb6dca941db2b.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv since r12-5944-ga7acb6dca941db2b
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
` (4 preceding siblings ...)
2021-12-23 8:32 ` [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv since r12-5944-ga7acb6dca941db2b marxin at gcc dot gnu.org
@ 2021-12-28 18:37 ` jakub at gcc dot gnu.org
2021-12-30 13:36 ` [Bug debug/103808] " cvs-commit at gcc dot gnu.org
2021-12-30 13:40 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-12-28 18:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It starts during var-tracking and not ix86_reorg.
The problem is we have:
(debug_insn 110 103 104 4 (var_location:TI D#2 (reg:TI 6 bp [orig:111 x ]
[111])) -1
(nil))
and
(debug_insn 25 24 26 3 (var_location:TI x (concatn/v:TI [
(reg:DI 6 bp [orig:111 x ] [111])
(subreg:DI (debug_expr:TI D#2) 8)
])) "pr103808.c":8:9 -1
(nil))
I guess it is originally from a paradoxical subreg or what, but RA can't
because of debug insns decide differently and not allocate pseudo 111 into bp
register.
When var-tracking.c attempts to simplify the (subreg:DI (reg:TI 6 bp [orig:111
x ] [111]) 8)
simplify-rtx.c calls gen_rtx_REG_offset which calls gen_rtx_REG and that
returns stack_pointer_rtx and later the function changes REG_ATTRS on that
shared rtx.
That is just wrong.
So, IMHO either gen_rtx_REG_offset should be changed to call gen_raw_REG
instead of gen_rtx_REG, or alternatively it shouldn't call update_reg_offset if
gen_rtx_REG returned one of the shared rtxes
({{frame,hard_frame,arg,return_address,stack}_pointer,pic_offset_table}_rtx).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug debug/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv since r12-5944-ga7acb6dca941db2b
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
` (5 preceding siblings ...)
2021-12-28 18:37 ` jakub at gcc dot gnu.org
@ 2021-12-30 13:36 ` cvs-commit at gcc dot gnu.org
2021-12-30 13:40 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-30 13:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
--- Comment #6 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:52441f18db7e051c16f2e6e12f415b93cb5450c4
commit r12-6153-g52441f18db7e051c16f2e6e12f415b93cb5450c4
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Dec 30 14:35:06 2021 +0100
emit-rtl: Fix a -fcompare-debug issue due to var-tracking [PR103808]
We get a -fcompare-debug FAIL on the following testcase. The problem is
that during cprop we get when a TImode pseudo holding x is being
constructed:
(debug_insn 111 59 103 7 (var_location:TI D#2 (clobber (const_int 0 [0])))
-1
(nil))
(insn 103 111 110 7 (clobber (reg/v:TI 89 [ x ])) "pr103808.c":8:9 -1
(nil))
(debug_insn 110 103 104 7 (var_location:TI D#2 (subreg:TI (reg:DI 111 [ x
]) 0)) -1
(nil))
(insn 104 110 109 7 (set (subreg:DI (reg/v:TI 89 [ x ]) 0)
(reg:DI 111 [ x ])) "pr103808.c":8:9 80 {*movdi_internal}
(expr_list:REG_DEAD (reg:DI 111 [ x ])
(nil)))
Now, during RA that paradoxical subreg in a debug insn obviously can't
affect where pseudo 111 is allocated and RA puts it into the bp register,
so we have:
(debug_insn 110 111 109 4 (var_location:TI D#2 (reg:TI 6 bp [orig:111 x ]
[111])) -1
(nil))
Now, during var-tracking when we for:
(debug_insn 25 23 26 3 (var_location:TI x (concatn/v:TI [
(reg:DI 6 bp [orig:111 x ] [111])
(subreg:DI (debug_expr:TI D#2) 8)
])) "pr103808.c":8:9 -1
(nil))
try to simplify the highpart subreg of bp, gen_rtx_REG_offset is called in:
if (HARD_REGISTER_NUM_P (final_regno))
{
rtx x = gen_rtx_REG_offset (op, outermode, final_regno,
subreg_memory_offset (outermode,
innermode,
byte));
and that unfortunately sets REG_ATTRS on stack_pointer_rtx, because
gen_rtx_REG_offset uses gen_rtx_REG which for Pmode STACK_POINTER_REGNUM
returns stack_pointer_rtx rather than newly created register.
The clobbering of REG_ATTRS on the shared stack_pointer_rtx then shows up
in the dumps as (reg/f:DI 7 sp [ x+8 ]) instead of (reg/f:DI 7 sp)
that shows up without var-tracking.
Clobbering of REG_ATTRS on the shared *_pointer_rtx looks just wrong.
So, IMHO either simplify_gen_subreg -> gen_rtx_REG_offset should call
gen_raw_REG to make sure we get a new non-shared REG we can set REG_ATTRS
on, or we should make sure that we don't overwrite the REG_ATTRS on the
shared REGs (but then simplify_gen_subreg shouldn't try to overwrite
ORIGINAL_REGNO on those either).
For non-DEBUG_INSNs, I'd hope this never happens, the RA shouldn't allocate
multi-word regs overlapping with stack pointer, hard frame pointer etc.
2021-12-30 Jakub Jelinek <jakub@redhat.com>
PR debug/103808
* emit-rtl.c (gen_rtx_REG_offset): Use gen_raw_REG instead of
gen_rtx_REG.
* gcc.dg/pr103808.c: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug debug/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv since r12-5944-ga7acb6dca941db2b
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
` (6 preceding siblings ...)
2021-12-30 13:36 ` [Bug debug/103808] " cvs-commit at gcc dot gnu.org
@ 2021-12-30 13:40 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-12-30 13:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103808
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-12-30 13:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 17:08 [Bug debug/103808] New: [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv asolokha at gmx dot com
2021-12-22 21:18 ` [Bug middle-end/103808] " pinskia at gcc dot gnu.org
2021-12-22 23:34 ` [Bug target/103808] " pinskia at gcc dot gnu.org
2021-12-22 23:36 ` pinskia at gcc dot gnu.org
2021-12-22 23:57 ` pinskia at gcc dot gnu.org
2021-12-23 8:32 ` [Bug target/103808] [12 Regression] '-fcompare-debug' failure (length) w/ -O2 -ftrapv since r12-5944-ga7acb6dca941db2b marxin at gcc dot gnu.org
2021-12-28 18:37 ` jakub at gcc dot gnu.org
2021-12-30 13:36 ` [Bug debug/103808] " cvs-commit at gcc dot gnu.org
2021-12-30 13:40 ` jakub 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).