public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102634] New: Optimization in dom2 pass makes wrong signed integer overflow inference
@ 2021-10-06 22:21 mk.aard.gcc at gmail dot com
2021-10-06 22:34 ` [Bug tree-optimization/102634] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: mk.aard.gcc at gmail dot com @ 2021-10-06 22:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102634
Bug ID: 102634
Summary: Optimization in dom2 pass makes wrong signed integer
overflow inference
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: mk.aard.gcc at gmail dot com
Target Milestone: ---
Created attachment 51563
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51563&action=edit
Sample code which fails. Integer with 'NaN' handling user type using min
integer value as NaN
Compiled using GCC 10.2.1 on Debian 11 Bullseye, amd64:
g++ -c -O2 -std=c++17 example.cpp
This generates the following assembly for strange_code() (see attached .ii)
00000000000000d0 <strange_code()>:
d0: 55 push %rbp
d1: 48 83 ec 10 sub $0x10,%rsp
d5: 48 c7 44 24 08 00 00 movq $0x0,0x8(%rsp)
dc: 00 00
de: 48 8d 6c 24 08 lea 0x8(%rsp),%rbp
e3: 48 89 ef mov %rbp,%rdi
e6: e8 00 00 00 00 callq eb <strange_code()+0x1b>
eb: 48 89 ef mov %rbp,%rdi
**ee: 48 be 00 00 00 00 00 movabs $0x8000000000000000,%rsi
f5: 00 00 80
f8: e8 00 00 00 00 callq fd <strange_code()+0x2d>
fd: 48 83 c4 10 add $0x10,%rsp
101: b8 01 00 00 00 mov $0x1,%eax
106: 5d pop %rbp
107: c3 retq
The use of 0x8000000000000000 as the argument for the second call we believe is
an incorrect optimization.
Although -fwrapv resolves this issue for us, and bug reporting guidelines
indicate that -fwrapv fixes are likely user error, I and several teammates have
been unable to find any signed integer overflow issues in the example provided.
As far as we can tell, each usage of the problematic value avoids any operation
which could cause overflow.
I apologize that the example isn't smaller, changing virtually anything in it
causes the issue to go away.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/102634] Optimization in dom2 pass makes wrong signed integer overflow inference
2021-10-06 22:21 [Bug tree-optimization/102634] New: Optimization in dom2 pass makes wrong signed integer overflow inference mk.aard.gcc at gmail dot com
@ 2021-10-06 22:34 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-06 22:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102634
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=98513
Resolution|--- |DUPLICATE
Known to fail| |10.2.0
Status|UNCONFIRMED |RESOLVED
Known to work| |10.3.0
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed already in GCC 10.3.0, a dup of bug 98513.
*** This bug has been marked as a duplicate of bug 98513 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-06 22:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 22:21 [Bug tree-optimization/102634] New: Optimization in dom2 pass makes wrong signed integer overflow inference mk.aard.gcc at gmail dot com
2021-10-06 22:34 ` [Bug tree-optimization/102634] " pinskia 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).