* [Bug tree-optimization/115661] wrong code at -O{2,3} on x86_64-linux-gnu
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
@ 2024-06-26 10:14 ` zhendong.su at inf dot ethz.ch
2024-06-26 10:35 ` [Bug tree-optimization/115661] [15 Regression] " rguenth at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2024-06-26 10:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
The following might be the same or related although it needs several flags to
trigger.
Compiler Explorer: https://godbolt.org/z/Y9414PbTh
[567] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240626 (experimental) (GCC)
[568] %
[568] % gcctk -O2 small.c; ./a.out
[569] %
[569] % gcctk -O2 -fno-tree-pre -fschedule-insns -fno-forward-propagate
-fno-guess-branch-probability -fno-gcse small.c
[570] % ./a.out
0
[571] %
[571] % cat small.c
int printf(const char *, ...);
struct {
unsigned : 8;
volatile unsigned b : 1;
int c : 31;
int d : 5;
} g, k, m, n, p;
unsigned e = 5;
volatile int f = 1;
int h, i, l, o, r, q;
long j, a;
int main() {
if (0)
L:
for (; e; e++)
;
for (; j < 5; j = 0)
if (f) {
int t = 7 - (((k.d | 7) ^ m.c) - a) - ~(n.b & -o), u, v = -t ^ q,
w = e - h;
u = k.d;
if (i) {
if (w > 6)
goto L;
printf("%d", l);
}
g.d = (g.d & (n.b - 5)) - (-((k.d - 7 - o) & t) ^ (v & q));
n.b = t;
m.c = ~(t - (7L & m.c));
k.d = ~(a & (m.c | ~o) & ~u) & g.d;
if ((unsigned) p.d >= e)
printf("0\n");
return 0;
}
return 0;
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2024-06-26 10:14 ` [Bug tree-optimization/115661] " zhendong.su at inf dot ethz.ch
@ 2024-06-26 10:35 ` rguenth at gcc dot gnu.org
2024-06-26 11:29 ` sjames at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-26 10:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|wrong code at -O{2,3} on |[15 Regression] wrong code
|x86_64-linux-gnu |at -O{2,3} on
| |x86_64-linux-gnu
Target Milestone|--- |15.0
Version|unknown |15.0
Keywords| |needs-bisection, wrong-code
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2024-06-26 10:14 ` [Bug tree-optimization/115661] " zhendong.su at inf dot ethz.ch
2024-06-26 10:35 ` [Bug tree-optimization/115661] [15 Regression] " rguenth at gcc dot gnu.org
@ 2024-06-26 11:29 ` sjames at gcc dot gnu.org
2024-06-26 11:34 ` [Bug tree-optimization/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4 sjames at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-26 11:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Evgeny.Karpov at microsoft dot com
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=115635
--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
Bisect says either of the two which is also in the range I suspected for
PR115635:
63512c72df09 Extract ix86 dllimport implementation to mingw
104d06c028c6 (HEAD) Move mingw_* declarations to the mingw folder
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (2 preceding siblings ...)
2024-06-26 11:29 ` sjames at gcc dot gnu.org
@ 2024-06-26 11:34 ` sjames at gcc dot gnu.org
2024-06-26 12:27 ` sjames at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-26 11:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
Ever confirmed|0 |1
Summary|[15 Regression] wrong code |[15 Regression] wrong code
|at -O{2,3} on |at -O{2,3} on
|x86_64-linux-gnu |x86_64-linux-gnu since
| |r15-1599-g63512c72df09b4
Last reconfirmed| |2024-06-26
Status|UNCONFIRMED |NEW
--- Comment #3 from Sam James <sjames at gcc dot gnu.org> ---
r15-1599-g63512c72df09b4, supposedly?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (3 preceding siblings ...)
2024-06-26 11:34 ` [Bug tree-optimization/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4 sjames at gcc dot gnu.org
@ 2024-06-26 12:27 ` sjames at gcc dot gnu.org
2024-06-26 13:30 ` [Bug target/115661] " rguenth at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-26 12:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
This fixes it for me as a hack:
```
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -412,20 +412,10 @@ ix86_expand_move (machine_mode mode, rtx operands[])
}
else
{
-#if TARGET_PECOFF
- tmp = legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
- if (tmp)
- {
- op1 = tmp;
- if (!addend)
- break;
- }
- else
{
op1 = operands[1];
break;
}
-#endif
}
if (addend)
```
Before r15-1599-g63512c72df09b4, legitimize_pe_coff_symbol would return
NULL_RTX for non-PECOFF targets, so the else branch would get taken.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (4 preceding siblings ...)
2024-06-26 12:27 ` sjames at gcc dot gnu.org
@ 2024-06-26 13:30 ` rguenth at gcc dot gnu.org
2024-06-26 18:43 ` Evgeny.Karpov at microsoft dot com
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-06-26 13:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note the ix86_GOT_alias_set change also looks wrong. AFAICS it now sets
MEM_ALIAS_SET to -1 which is ALIAS_SET_MEMORY_BARRIER and a pessimization.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (5 preceding siblings ...)
2024-06-26 13:30 ` [Bug target/115661] " rguenth at gcc dot gnu.org
@ 2024-06-26 18:43 ` Evgeny.Karpov at microsoft dot com
2024-06-26 23:45 ` sjames at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Evgeny.Karpov at microsoft dot com @ 2024-06-26 18:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
--- Comment #6 from Evgeny Karpov <Evgeny.Karpov at microsoft dot com> ---
Sorry for the regression.
I am working on the fix and will try to validate and submit it today.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (6 preceding siblings ...)
2024-06-26 18:43 ` Evgeny.Karpov at microsoft dot com
@ 2024-06-26 23:45 ` sjames at gcc dot gnu.org
2024-06-27 5:00 ` sjames at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-26 23:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |Evgeny.Karpov at microsoft dot com
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (7 preceding siblings ...)
2024-06-26 23:45 ` sjames at gcc dot gnu.org
@ 2024-06-27 5:00 ` sjames at gcc dot gnu.org
2024-06-27 7:24 ` Evgeny.Karpov at microsoft dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-06-27 5:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
--- Comment #7 from Sam James <sjames at gcc dot gnu.org> ---
To the reporter: I should say, thanks for finding this so quickly - it made it
a lot easier to debug.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (8 preceding siblings ...)
2024-06-27 5:00 ` sjames at gcc dot gnu.org
@ 2024-06-27 7:24 ` Evgeny.Karpov at microsoft dot com
2024-06-28 12:47 ` cvs-commit at gcc dot gnu.org
2024-06-28 12:50 ` clyon at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: Evgeny.Karpov at microsoft dot com @ 2024-06-27 7:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
--- Comment #8 from Evgeny Karpov <Evgeny.Karpov at microsoft dot com> ---
Thank you for reporting the issues and discussing the root causes.
It helped in preparing the patch.
The patch is under review.
https://gcc.gnu.org/pipermail/gcc-patches/2024-June/655807.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (9 preceding siblings ...)
2024-06-27 7:24 ` Evgeny.Karpov at microsoft dot com
@ 2024-06-28 12:47 ` cvs-commit at gcc dot gnu.org
2024-06-28 12:50 ` clyon at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-28 12:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Christophe Lyon <clyon@gcc.gnu.org>:
https://gcc.gnu.org/g:c4b7b62bfa10816c1e08f0f9597d857f11379688
commit r15-1708-gc4b7b62bfa10816c1e08f0f9597d857f11379688
Author: Evgeny Karpov <Evgeny.Karpov@microsoft.com>
Date: Fri Jun 28 12:37:12 2024 +0000
i386: Fix regression after refactoring legitimize_pe_coff_symbol,
ix86_GOT_alias_set and PE_COFF_LEGITIMIZE_EXTERN_DECL [PR115635]
This patch fixes 3 bugs reported after merging the "Add DLL
import/export implementation to AArch64" series.
https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653955.html The
series refactors the i386 codebase to reuse it in AArch64, which
triggers some bugs.
Bug 115661 - [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu
since r15-1599-g63512c72df09b4
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Bug 115635 - [15 regression] Bootstrap fails with failed self-test
with the rust fe (diagnostic-path.cc:1153: test_empty_path: FAIL:
ASSERT_FALSE ((path.interprocedural_p ()))) since
r15-1599-g63512c72df09b4
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115635
Issue 1. In some code, i386 has been relying on the
legitimize_pe_coff_symbol call on all platforms and should return
NULL_RTX if it is not supported.
Fix: NULL_RTX handling has been added when the target does not support
PECOFF.
Issue 2. ix86_GOT_alias_set is used on all platforms and cannot be
extracted to mingw.
Fix: ix86_GOT_alias_set has been returned as it was and is used on all
platforms for i386.
Bug 115643 - [15 regression] aarch64-w64-mingw32 support today breaks
x86_64-w64-mingw32 build cannot represent relocation type BFD_RELOC_64
since r15-1602-ged20feebd9ea31
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115643
Issue 3. PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED has been added and
used with a negative operator for a complex expression without braces.
Fix: Braces has been added, and
PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED has been renamed to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
2024-06-28 Evgeny Karpov <Evgeny.Karpov@microsoft.com>
gcc/ChangeLog:
PR bootstrap/115635
PR target/115643
PR target/115661
* config/aarch64/cygming.h
(PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED): Rename to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
(PE_COFF_LEGITIMIZE_EXTERN_DECL): Likewise.
* config/i386/cygming.h (GOT_ALIAS_SET): Remove the diffinition to
reuse it from i386.h.
(PE_COFF_EXTERN_DECL_SHOULD_BE_LEGITIMIZED): Rename to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
(PE_COFF_LEGITIMIZE_EXTERN_DECL): Likewise.
* config/i386/i386-expand.cc (ix86_expand_move): Return
ix86_GOT_alias_set.
* config/i386/i386-expand.h (ix86_GOT_alias_set): Likewise.
* config/i386/i386.cc (ix86_GOT_alias_set): Likewise.
* config/i386/i386.h (GOT_ALIAS_SET): Likewise.
* config/mingw/winnt-dll.cc (get_dllimport_decl): Use
GOT_ALIAS_SET.
(legitimize_pe_coff_symbol): Rename to
PE_COFF_LEGITIMIZE_EXTERN_DECL.
* config/mingw/winnt-dll.h (ix86_GOT_alias_set): Declare
ix86_GOT_alias_set.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug target/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (10 preceding siblings ...)
2024-06-28 12:47 ` cvs-commit at gcc dot gnu.org
@ 2024-06-28 12:50 ` clyon at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: clyon at gcc dot gnu.org @ 2024-06-28 12:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Christophe Lyon <clyon at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #10 from Christophe Lyon <clyon at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread