public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
@ 2024-03-01 12:11 zsojka at seznam dot cz
2024-03-01 20:58 ` [Bug target/114190] " pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2024-03-01 12:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
Bug ID: 114190
Summary: wrong code with -O2 -fno-dce -fharden-compares
-mvpclmulqdq
--param=max-rtl-if-conversion-unpredictable-cost=136
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Created attachment 57585
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57585&action=edit
reduced testcase
Output:
$ x86_64-pc-linux-gnu-gcc -O2 -fno-dce -fharden-compares -mvpclmulqdq
--param=max-rtl-if-conversion-unpredictable-cost=136 testcase.c -Wno-psabi
$ ./a.out
Aborted
$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-9248-20240301110451-gd3d0fcb6527-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --enable-libsanitizer
--disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-9248-20240301110451-gd3d0fcb6527-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240301 (experimental) (GCC)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/114190] wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
@ 2024-03-01 20:58 ` pinskia at gcc dot gnu.org
2024-03-01 21:04 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-01 20:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> test esi, esi
is missing with `-fno-dce`
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/114190] wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
2024-03-01 20:58 ` [Bug target/114190] " pinskia at gcc dot gnu.org
@ 2024-03-01 21:04 ` pinskia at gcc dot gnu.org
2024-03-01 21:08 ` [Bug rtl-optimization/114190] " pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-01 21:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So after reload, it looks ok:
(insn 22 21 380 2 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:SI 4 si [orig:111 _21+4 ] [111])
(const_int 0 [0]))) "/app/example.cpp":8:8 discrim 1 7
{*cmpsi_ccno_1}
(nil))
(insn 380 22 381 2 (parallel [
(set (reg:DI 1 dx [353])
(plus:DI (reg/f:DI 7 sp)
(const_int 212 [0xd4])))
(clobber (reg:CC 17 flags))
]) "/app/example.cpp":8:65 discrim 1 272 {*adddi_1}
(expr_list:REG_EQUIV (plus:DI (reg/f:DI 16 argp)
(const_int 76 [0x4c]))
(nil)))
(insn 381 380 466 2 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:SI 4 si [orig:111 _21+4 ] [111])
(const_int 0 [0]))) "/app/example.cpp":8:65 discrim 1 7
{*cmpsi_ccno_1}
(nil))
Note without -fno-dce, `insn 22` is not in the IR and that is the only
difference so far. THis is ok at this point.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/114190] wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
2024-03-01 20:58 ` [Bug target/114190] " pinskia at gcc dot gnu.org
2024-03-01 21:04 ` pinskia at gcc dot gnu.org
@ 2024-03-01 21:08 ` pinskia at gcc dot gnu.org
2024-03-04 8:10 ` [Bug rtl-optimization/114190] [14 regression] Wrong " rguenth at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-01 21:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2024-03-01
Component|target |rtl-optimization
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
cmpelim produces:
```
(insn 22 21 486 2 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:SI 4 si [orig:111 _21+4 ] [111])
(const_int 0 [0]))) "/app/example.cpp":8:8 discrim 1 7
{*cmpsi_ccno_1}
(expr_list:REG_UNUSED (reg:CCZ 17 flags)
(nil)))
(insn 486 22 466 2 (set (reg:DI 1 dx [353])
(plus:DI (reg/f:DI 7 sp)
(const_int 212 [0xd4]))) "/app/example.cpp":8:65 discrim 1 254
{*leadi}
(nil))
(insn 466 486 383 2 (set (reg:DI 4 si [354])
(const:DI (plus:DI (symbol_ref:DI ("u") [flags 0x2] <var_decl
0x7fe775410c60 u>)
(const_int 1 [0x1])))) "/app/example.cpp":8:65 discrim 1 84
{*movdi_internal}
(expr_list:REG_EQUIV (const:DI (plus:DI (symbol_ref:DI ("u") [flags 0x2]
<var_decl 0x7fe775410c60 u>)
(const_int 1 [0x1])))
(nil)))
(insn 383 466 384 2 (set (reg:DI 1 dx [348])
(if_then_else:DI (eq (reg:CCZ 17 flags)
(const_int 0 [0]))
(reg:DI 1 dx [353])
(reg:DI 4 si [354]))) "/app/example.cpp":8:65 discrim 1 1451
{*movdicc_noc}
(expr_list:REG_DEAD (reg:CCZ 17 flags)
(expr_list:REG_DEAD (reg:DI 4 si [354])
(nil))))
```
Which is fine (but note the REG_UNUSED note which was not updated).
From pro_and_epilogue's dump:
deleting insn with uid = 22.
Which is totally bogus; I think someone didn't redo REG_UNUSED notes again.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/114190] [14 regression] Wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
` (2 preceding siblings ...)
2024-03-01 21:08 ` [Bug rtl-optimization/114190] " pinskia at gcc dot gnu.org
@ 2024-03-04 8:10 ` rguenth at gcc dot gnu.org
2024-03-04 13:19 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-04 8:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/114190] [14 regression] Wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
` (3 preceding siblings ...)
2024-03-04 8:10 ` [Bug rtl-optimization/114190] [14 regression] Wrong " rguenth at gcc dot gnu.org
@ 2024-03-04 13:19 ` rguenth at gcc dot gnu.org
2024-03-05 8:02 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-04 13:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/114190] [14 regression] Wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
` (4 preceding siblings ...)
2024-03-04 13:19 ` rguenth at gcc dot gnu.org
@ 2024-03-05 8:02 ` jakub at gcc dot gnu.org
2024-03-05 9:19 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-05 8:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r14-5355-g3cd3a09b3f91a1d023cb180763d40598d6bb274b
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/114190] [14 regression] Wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
` (5 preceding siblings ...)
2024-03-05 8:02 ` jakub at gcc dot gnu.org
@ 2024-03-05 9:19 ` jakub at gcc dot gnu.org
2024-03-06 8:36 ` cvs-commit at gcc dot gnu.org
2024-03-06 8:37 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-05 9:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
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
Status|NEW |ASSIGNED
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57611
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57611&action=edit
gcc14-pr114190.patch
Untested fix. After removing the REG_DEAD/REG_UNUSED notes the pass calls
df_analyze, but as problems are normally only removed during df_finish_pass,
the note problem is still requested and the df_analyze recreates the notes
again.
We could just move the df_analyze before the manual note removal, but I think
it is a waste of time to compute the notes again there.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/114190] [14 regression] Wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
` (6 preceding siblings ...)
2024-03-05 9:19 ` jakub at gcc dot gnu.org
@ 2024-03-06 8:36 ` cvs-commit at gcc dot gnu.org
2024-03-06 8:37 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-06 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
--- Comment #6 from GCC 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:1157d5de35b41eabe5ee51d532224864173c37bd
commit r14-9329-g1157d5de35b41eabe5ee51d532224864173c37bd
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Mar 6 09:35:37 2024 +0100
i386: Fix up the vzeroupper REG_DEAD/REG_UNUSED note workaround [PR114190]
When writing the rest_of_handle_insert_vzeroupper workaround to manually
remove all the REG_DEAD/REG_UNUSED notes from the IL, I've missed that
there is a df_analyze () call right after it and that the problems added
earlier in the pass, like df_note_add_problem () done during mode
switching,
doesn't affect just the next df_analyze () call right after it, but all
other df_analyze () calls until the end of the current pass where
df_finish_pass removes the optional problems.
So, as can be seen on the following patch, the workaround doesn't actually
work there, because while rest_of_handle_insert_vzeroupper carefully
removes
all REG_DEAD/REG_UNUSED notes, the df_analyze () call at the end of the
function immediately adds them in again (so, I must say I have no idea
why the workaround worked on the earlier testcases).
Now, I could move the df_analyze () call just before the
REG_DEAD/REG_UNUSED
note removal loop, but I think the following patch is better, because
the df_analyze () call doesn't have to recompute the problem when we don't
care about it and will actively strip all traces of it away.
2024-03-06 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/114190
* config/i386/i386-features.cc (rest_of_handle_insert_vzeroupper):
Call df_remove_problem for df_note before calling df_analyze.
* gcc.target/i386/avx-pr114190.c: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug rtl-optimization/114190] [14 regression] Wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
` (7 preceding siblings ...)
2024-03-06 8:36 ` cvs-commit at gcc dot gnu.org
@ 2024-03-06 8:37 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-06 8:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114190
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-03-06 8:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01 12:11 [Bug tree-optimization/114190] New: wrong code with -O2 -fno-dce -fharden-compares -mvpclmulqdq --param=max-rtl-if-conversion-unpredictable-cost=136 zsojka at seznam dot cz
2024-03-01 20:58 ` [Bug target/114190] " pinskia at gcc dot gnu.org
2024-03-01 21:04 ` pinskia at gcc dot gnu.org
2024-03-01 21:08 ` [Bug rtl-optimization/114190] " pinskia at gcc dot gnu.org
2024-03-04 8:10 ` [Bug rtl-optimization/114190] [14 regression] Wrong " rguenth at gcc dot gnu.org
2024-03-04 13:19 ` rguenth at gcc dot gnu.org
2024-03-05 8:02 ` jakub at gcc dot gnu.org
2024-03-05 9:19 ` jakub at gcc dot gnu.org
2024-03-06 8:36 ` cvs-commit at gcc dot gnu.org
2024-03-06 8:37 ` 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).