public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
@ 2022-03-07 9:39 stefansf at linux dot ibm.com
2022-03-07 9:40 ` [Bug rtl-optimization/104814] " stefansf at linux dot ibm.com
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: stefansf at linux dot ibm.com @ 2022-03-07 9:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Bug ID: 104814
Summary: [10/11/12 Regression] ifcvt: Deleting live variable in
IF-CASE-2
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: stefansf at linux dot ibm.com
Target Milestone: ---
Target: s390x-*-*
Created attachment 52570
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52570&action=edit
dump ce2
short a = 0;
static long b = 0;
int c = 7;
char d = 0;
short *e = &a;
long f = 0;
unsigned long g (unsigned long h, long j) { return j == 0 ? h : h / j; }
int main (void) {
long k = f;
for (; c; --c) {
for (int i = 0; i < 7; ++i)
;
long m = g (f, --b);
d = ((char)m | *e) <= 43165;
}
if (b != -7)
__builtin_abort ();
return 0;
}
Variable b should be decremented in each iteration of the outer loop and thus
equal -7 at the end.
After combine a load, decrement, and store insn exists:
(insn 13 12 14 3 (set (reg:DI 62 [ b_lsm.16 ])
(mem/c:DI (const:DI (plus:DI (symbol_ref:DI ("*.LANCHOR0") [flags
0x182])
(const_int 8 [0x8]))) [1 b+0 S8 A64])) 1469 {*movdi_64}
(nil))
(jump_insn 40 39 46 6 (parallel [
(set (pc)
(if_then_else (ne (reg:DI 62 [ b_lsm.16 ])
(const_int 1 [0x1]))
(label_ref 38)
(pc)))
(set (reg:DI 62 [ b_lsm.16 ])
(plus:DI (reg:DI 62 [ b_lsm.16 ])
(const_int -1 [0xffffffffffffffff])))
(clobber (scratch:DI))
(clobber (reg:CC 33 %cc))
]) "t.c":8:63 2164 {doloop_di}
(expr_list:REG_UNUSED (reg:CC 33 %cc)
(int_list:REG_BR_PROB 536870916 (nil)))
-> 38)
(insn 48 47 49 7 (set (mem/c:DI (const:DI (plus:DI (symbol_ref:DI
("*.LANCHOR0") [flags 0x182])
(const_int 8 [0x8]))) [1 b+0 S8 A64])
(reg:DI 62 [ b_lsm.16 ])) 1469 {*movdi_64}
(expr_list:REG_DEAD (reg:DI 62 [ b_lsm.16 ])
(nil)))
Pass ce2 deletes jump insn 40 including the decrement of variable b:
IF-CASE-2 found, start 6, else 4
deleting insn with uid = 40.
deleting block 4
Conversion succeeded on pass 1.
Thus variable b equals 0 in the end.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
@ 2022-03-07 9:40 ` stefansf at linux dot ibm.com
2022-03-07 9:56 ` rguenth at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: stefansf at linux dot ibm.com @ 2022-03-07 9:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
--- Comment #1 from Stefan Schulze Frielinghaus <stefansf at linux dot ibm.com> ---
Created attachment 52571
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52571&action=edit
dump combine
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
2022-03-07 9:40 ` [Bug rtl-optimization/104814] " stefansf at linux dot ibm.com
@ 2022-03-07 9:56 ` rguenth at gcc dot gnu.org
2022-03-07 14:41 ` jakub at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-07 9:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
2022-03-07 9:40 ` [Bug rtl-optimization/104814] " stefansf at linux dot ibm.com
2022-03-07 9:56 ` rguenth at gcc dot gnu.org
@ 2022-03-07 14:41 ` jakub at gcc dot gnu.org
2022-03-07 16:05 ` stefansf at linux dot ibm.com
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-07 14:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
What options is this with? Which isa/tuning?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (2 preceding siblings ...)
2022-03-07 14:41 ` jakub at gcc dot gnu.org
@ 2022-03-07 16:05 ` stefansf at linux dot ibm.com
2022-03-09 9:36 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: stefansf at linux dot ibm.com @ 2022-03-07 16:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
--- Comment #3 from Stefan Schulze Frielinghaus <stefansf at linux dot ibm.com> ---
Oh forgot to mention it is just: gcc -O1 t.c
Works fine with -O{0,2,3}
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (3 preceding siblings ...)
2022-03-07 16:05 ` stefansf at linux dot ibm.com
@ 2022-03-09 9:36 ` rguenth at gcc dot gnu.org
2022-03-11 16:46 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-09 9:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (4 preceding siblings ...)
2022-03-09 9:36 ` rguenth at gcc dot gnu.org
@ 2022-03-11 16:46 ` jakub at gcc dot gnu.org
2022-03-15 8:14 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-11 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Last reconfirmed| |2022-03-11
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 52612
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52612&action=edit
gcc12-pr104814.patch
Untested fix.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (5 preceding siblings ...)
2022-03-11 16:46 ` jakub at gcc dot gnu.org
@ 2022-03-15 8:14 ` cvs-commit at gcc dot gnu.org
2022-03-15 8:20 ` [Bug rtl-optimization/104814] [10/11 " jakub at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-15 8:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
--- Comment #5 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:a2645cd8fb33b36d737b310e26f4c47401305c7b
commit r12-7651-ga2645cd8fb33b36d737b310e26f4c47401305c7b
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 15 09:12:03 2022 +0100
ifcvt: Punt if not onlyjump_p for find_if_case_{1,2} [PR104814]
find_if_case_{1,2} implicitly assumes conditional jumps and rewrites them,
so if they have extra side-effects or are say asm goto, things don't work
well, either the side-effects are lost or we could ICE.
In particular, the testcase below on s390x has there a doloop instruction
that decrements a register in addition to testing it for non-zero and
conditionally jumping based on that.
The following patch fixes that by punting for !onlyjump_p case, i.e.
if there are side-effects in the jump instruction or it isn't a plain PC
setter.
Also, it assumes BB_END (test_bb) will be always non-NULL, because basic
blocks with 2 non-abnormal successor edges should always have some
instruction
at the end that determines which edge to take.
2022-03-15 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/104814
* ifcvt.cc (find_if_case_1, find_if_case_2): Punt if test_bb
doesn't
end with onlyjump_p. Assume BB_END (test_bb) is always non-NULL.
* gcc.c-torture/execute/pr104814.c: New test.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (6 preceding siblings ...)
2022-03-15 8:14 ` cvs-commit at gcc dot gnu.org
@ 2022-03-15 8:20 ` jakub at gcc dot gnu.org
2022-03-15 12:24 ` stefansf at linux dot ibm.com
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-15 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11/12 Regression] |[10/11 Regression] ifcvt:
|ifcvt: Deleting live |Deleting live variable in
|variable in IF-CASE-2 |IF-CASE-2
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (7 preceding siblings ...)
2022-03-15 8:20 ` [Bug rtl-optimization/104814] [10/11 " jakub at gcc dot gnu.org
@ 2022-03-15 12:24 ` stefansf at linux dot ibm.com
2022-03-29 5:54 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: stefansf at linux dot ibm.com @ 2022-03-15 12:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
--- Comment #7 from Stefan Schulze Frielinghaus <stefansf at linux dot ibm.com> ---
Gave trunk a try and it worked fine for me. Thanks for the fix!
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10/11 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (8 preceding siblings ...)
2022-03-15 12:24 ` stefansf at linux dot ibm.com
@ 2022-03-29 5:54 ` cvs-commit at gcc dot gnu.org
2022-03-30 8:16 ` [Bug rtl-optimization/104814] [10 " jakub at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-29 5:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
--- Comment #8 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:17de662ec26786053caab2cea34c76814352ea4d
commit r11-9727-g17de662ec26786053caab2cea34c76814352ea4d
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 15 09:12:03 2022 +0100
ifcvt: Punt if not onlyjump_p for find_if_case_{1,2} [PR104814]
find_if_case_{1,2} implicitly assumes conditional jumps and rewrites them,
so if they have extra side-effects or are say asm goto, things don't work
well, either the side-effects are lost or we could ICE.
In particular, the testcase below on s390x has there a doloop instruction
that decrements a register in addition to testing it for non-zero and
conditionally jumping based on that.
The following patch fixes that by punting for !onlyjump_p case, i.e.
if there are side-effects in the jump instruction or it isn't a plain PC
setter.
Also, it assumes BB_END (test_bb) will be always non-NULL, because basic
blocks with 2 non-abnormal successor edges should always have some
instruction
at the end that determines which edge to take.
2022-03-15 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/104814
* ifcvt.c (find_if_case_1, find_if_case_2): Punt if test_bb doesn't
end with onlyjump_p. Assume BB_END (test_bb) is always non-NULL.
* gcc.c-torture/execute/pr104814.c: New test.
(cherry picked from commit a2645cd8fb33b36d737b310e26f4c47401305c7b)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (9 preceding siblings ...)
2022-03-29 5:54 ` cvs-commit at gcc dot gnu.org
@ 2022-03-30 8:16 ` jakub at gcc dot gnu.org
2022-05-10 8:25 ` cvs-commit at gcc dot gnu.org
2022-05-10 10:25 ` jakub at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-30 8:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11 Regression] ifcvt: |[10 Regression] ifcvt:
|Deleting live variable in |Deleting live variable in
|IF-CASE-2 |IF-CASE-2
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.3 too.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (10 preceding siblings ...)
2022-03-30 8:16 ` [Bug rtl-optimization/104814] [10 " jakub at gcc dot gnu.org
@ 2022-05-10 8:25 ` cvs-commit at gcc dot gnu.org
2022-05-10 10:25 ` jakub at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-10 8:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
--- Comment #10 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:1ebc65fde4dd30678da10a17c6cc29bc4e1e041e
commit r10-10694-g1ebc65fde4dd30678da10a17c6cc29bc4e1e041e
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 15 09:12:03 2022 +0100
ifcvt: Punt if not onlyjump_p for find_if_case_{1,2} [PR104814]
find_if_case_{1,2} implicitly assumes conditional jumps and rewrites them,
so if they have extra side-effects or are say asm goto, things don't work
well, either the side-effects are lost or we could ICE.
In particular, the testcase below on s390x has there a doloop instruction
that decrements a register in addition to testing it for non-zero and
conditionally jumping based on that.
The following patch fixes that by punting for !onlyjump_p case, i.e.
if there are side-effects in the jump instruction or it isn't a plain PC
setter.
Also, it assumes BB_END (test_bb) will be always non-NULL, because basic
blocks with 2 non-abnormal successor edges should always have some
instruction
at the end that determines which edge to take.
2022-03-15 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/104814
* ifcvt.c (find_if_case_1, find_if_case_2): Punt if test_bb doesn't
end with onlyjump_p. Assume BB_END (test_bb) is always non-NULL.
* gcc.c-torture/execute/pr104814.c: New test.
(cherry picked from commit a2645cd8fb33b36d737b310e26f4c47401305c7b)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug rtl-optimization/104814] [10 Regression] ifcvt: Deleting live variable in IF-CASE-2
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
` (11 preceding siblings ...)
2022-05-10 8:25 ` cvs-commit at gcc dot gnu.org
@ 2022-05-10 10:25 ` jakub at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-10 10:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104814
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10.4 too.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-05-10 10:25 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 9:39 [Bug rtl-optimization/104814] New: [10/11/12 Regression] ifcvt: Deleting live variable in IF-CASE-2 stefansf at linux dot ibm.com
2022-03-07 9:40 ` [Bug rtl-optimization/104814] " stefansf at linux dot ibm.com
2022-03-07 9:56 ` rguenth at gcc dot gnu.org
2022-03-07 14:41 ` jakub at gcc dot gnu.org
2022-03-07 16:05 ` stefansf at linux dot ibm.com
2022-03-09 9:36 ` rguenth at gcc dot gnu.org
2022-03-11 16:46 ` jakub at gcc dot gnu.org
2022-03-15 8:14 ` cvs-commit at gcc dot gnu.org
2022-03-15 8:20 ` [Bug rtl-optimization/104814] [10/11 " jakub at gcc dot gnu.org
2022-03-15 12:24 ` stefansf at linux dot ibm.com
2022-03-29 5:54 ` cvs-commit at gcc dot gnu.org
2022-03-30 8:16 ` [Bug rtl-optimization/104814] [10 " jakub at gcc dot gnu.org
2022-05-10 8:25 ` cvs-commit at gcc dot gnu.org
2022-05-10 10:25 ` 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).