public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu
@ 2022-06-28 9:59 zhendong.su at inf dot ethz.ch
2022-06-28 10:00 ` [Bug tree-optimization/106112] " zhendong.su at inf dot ethz.ch
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2022-06-28 9:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
Bug ID: 106112
Summary: wrong code at -Os and above on x86_64-linux-gnu
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zhendong.su at inf dot ethz.ch
Target Milestone: ---
It appears to be a regression from 9.*, and affect 10.* and later.
[574] % 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/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--prefix=/local/suz-local/software/local/gcc-trunk --enable-sanitizers
--enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20220628 (experimental) [master r13-1313-gf9764ea128c] (GCC)
[575] %
[575] % gcctk -O1 small.c; ./a.out
[576] %
[576] % gcctk -Os small.c
[577] % ./a.out
Aborted
[578] %
[578] % cat small.c
int a = 5, b, c, d;
unsigned long e = 20862985922;
int main() {
unsigned f = 4294967292;
e = e | f;
c = -1 % ((~f ^ 4294967292) - (e - d));
b = ~-~e % ~-d;
if (b)
a = 0;
if (a < 1)
__builtin_abort();
return 0;
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] wrong code at -Os and above on x86_64-linux-gnu
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
@ 2022-06-28 10:00 ` zhendong.su at inf dot ethz.ch
2022-06-28 11:13 ` [Bug tree-optimization/106112] [10/11/12/13 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80 marxin at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2022-06-28 10:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Compiler Explorer: https://godbolt.org/z/v6qY9d6q6
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10/11/12/13 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2022-06-28 10:00 ` [Bug tree-optimization/106112] " zhendong.su at inf dot ethz.ch
@ 2022-06-28 11:13 ` marxin at gcc dot gnu.org
2022-06-28 11:54 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-28 11:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-06-28
CC| |marxin at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
Version|unknown |13.0
Summary|wrong code at -Os and above |[10/11/12/13 Regression]
|on x86_64-linux-gnu |wrong code at -Os and above
| |on x86_64-linux-gnu since
| |r10-2711-g3ed01d5408045d80
Target Milestone|--- |10.5
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r10-2711-g3ed01d5408045d80.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10/11/12/13 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2022-06-28 10:00 ` [Bug tree-optimization/106112] " zhendong.su at inf dot ethz.ch
2022-06-28 11:13 ` [Bug tree-optimization/106112] [10/11/12/13 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80 marxin at gcc dot gnu.org
@ 2022-06-28 11:54 ` rguenth at gcc dot gnu.org
2022-06-29 9:15 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-28 11:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
<bb 2> [local count: 1073741824]:
e.0_1 = e;
_2 = e.0_1 | 4294967292;
e = _2;
d.1_3 = d;
_4 = (long unsigned int) d.1_3;
- # RANGE [2147483647, 6442450942] NONZERO 8589934591
+ # RANGE ~[2147483647, 18446744071562067967]
_10 = _4 + 4294967295;
_7 = _10 - _2;
_8 = 18446744073709551615 % _7;
_9 = (int) _8;
c = _9;
_11 = 18446744073709551614 - _2;
- _13 = d.1_3 + -1;
- # RANGE ~[2147483647, 18446744071562067967]
- _14 = (long unsigned int) _13;
- _15 = _11 % _14;
+ _15 = _11 % _10;
is the key change, replacing (unsigned long)(intvar + -1) with (unsigned
long)intvar + 4294967295
It looks like
/* For constants simply extend it. */
if (TREE_CODE (op) == INTEGER_CST)
return wide_int_to_tree (wide_type, wi::to_wide (op));
doesn't sign-extend the -1 from int to unsigned log. Using wi::to_widest
does and fixes the testcase.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10/11/12/13 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (2 preceding siblings ...)
2022-06-28 11:54 ` rguenth at gcc dot gnu.org
@ 2022-06-29 9:15 ` cvs-commit at gcc dot gnu.org
2022-06-29 9:18 ` [Bug tree-optimization/106112] [10/11/12 " rguenth at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-29 9:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:2dbb45d6dc0d20dc159b3d8e27ebb6825074827a
commit r13-1341-g2dbb45d6dc0d20dc159b3d8e27ebb6825074827a
Author: Richard Biener <rguenther@suse.de>
Date: Tue Jun 28 13:57:29 2022 +0200
tree-optimization/106112 - fix CSE from wider operation
The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.
2022-06-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/106112
* tree-ssa-sccvn.cc (valueized_wider_op): Properly extend
a constant operand according to its type.
* gcc.dg/torture/pr106112.c: New testcase.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10/11/12 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (3 preceding siblings ...)
2022-06-29 9:15 ` cvs-commit at gcc dot gnu.org
@ 2022-06-29 9:18 ` rguenth at gcc dot gnu.org
2022-07-19 11:38 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-29 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |12.1.0
Summary|[10/11/12/13 Regression] |[10/11/12 Regression] wrong
|wrong code at -Os and above |code at -Os and above on
|on x86_64-linux-gnu since |x86_64-linux-gnu since
|r10-2711-g3ed01d5408045d80 |r10-2711-g3ed01d5408045d80
Known to work| |13.0
Priority|P3 |P2
Keywords| |wrong-code
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10/11/12 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (4 preceding siblings ...)
2022-06-29 9:18 ` [Bug tree-optimization/106112] [10/11/12 " rguenth at gcc dot gnu.org
@ 2022-07-19 11:38 ` cvs-commit at gcc dot gnu.org
2022-10-11 13:04 ` [Bug tree-optimization/106112] [10/11 " cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-19 11:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:854ab8be5d9ddfc5b4d57a5c040d1811a89fbe4f
commit r12-8582-g854ab8be5d9ddfc5b4d57a5c040d1811a89fbe4f
Author: Richard Biener <rguenther@suse.de>
Date: Tue Jun 28 13:57:29 2022 +0200
tree-optimization/106112 - fix CSE from wider operation
The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.
2022-06-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/106112
* tree-ssa-sccvn.cc (valueized_wider_op): Properly extend
a constant operand according to its type.
* gcc.dg/torture/pr106112.c: New testcase.
(cherry picked from commit 2dbb45d6dc0d20dc159b3d8e27ebb6825074827a)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10/11 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (5 preceding siblings ...)
2022-07-19 11:38 ` cvs-commit at gcc dot gnu.org
@ 2022-10-11 13:04 ` cvs-commit at gcc dot gnu.org
2022-10-14 10:47 ` [Bug tree-optimization/106112] [10 " cvs-commit at gcc dot gnu.org
2022-10-14 10:47 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-11 13:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:b7878f05553bcf569a987dff8a7ef8b045b8d26c
commit r11-10303-gb7878f05553bcf569a987dff8a7ef8b045b8d26c
Author: Richard Biener <rguenther@suse.de>
Date: Tue Jun 28 13:57:29 2022 +0200
tree-optimization/106112 - fix CSE from wider operation
The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.
2022-06-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/106112
* tree-ssa-sccvn.c (valueized_wider_op): Properly extend
a constant operand according to its type.
* gcc.dg/torture/pr106112.c: New testcase.
(cherry picked from commit 2dbb45d6dc0d20dc159b3d8e27ebb6825074827a)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (6 preceding siblings ...)
2022-10-11 13:04 ` [Bug tree-optimization/106112] [10/11 " cvs-commit at gcc dot gnu.org
@ 2022-10-14 10:47 ` cvs-commit at gcc dot gnu.org
2022-10-14 10:47 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-14 10:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:983d87530d8efbae6b5f4973c52edd1071d26add
commit r10-11035-g983d87530d8efbae6b5f4973c52edd1071d26add
Author: Richard Biener <rguenther@suse.de>
Date: Tue Jun 28 13:57:29 2022 +0200
tree-optimization/106112 - fix CSE from wider operation
The following fixes a mistake in looking up an extended operand
in the CSE of a truncated operation.
2022-06-28 Richard Biener <rguenther@suse.de>
PR tree-optimization/106112
* tree-ssa-sccvn.c (valueized_wider_op): Properly extend
a constant operand according to its type.
* gcc.dg/torture/pr106112.c: New testcase.
(cherry picked from commit 2dbb45d6dc0d20dc159b3d8e27ebb6825074827a)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/106112] [10 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
` (7 preceding siblings ...)
2022-10-14 10:47 ` [Bug tree-optimization/106112] [10 " cvs-commit at gcc dot gnu.org
@ 2022-10-14 10:47 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-14 10:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106112
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |10.4.0
Known to work| |10.4.1
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-10-14 10:47 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 9:59 [Bug tree-optimization/106112] New: wrong code at -Os and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2022-06-28 10:00 ` [Bug tree-optimization/106112] " zhendong.su at inf dot ethz.ch
2022-06-28 11:13 ` [Bug tree-optimization/106112] [10/11/12/13 Regression] wrong code at -Os and above on x86_64-linux-gnu since r10-2711-g3ed01d5408045d80 marxin at gcc dot gnu.org
2022-06-28 11:54 ` rguenth at gcc dot gnu.org
2022-06-29 9:15 ` cvs-commit at gcc dot gnu.org
2022-06-29 9:18 ` [Bug tree-optimization/106112] [10/11/12 " rguenth at gcc dot gnu.org
2022-07-19 11:38 ` cvs-commit at gcc dot gnu.org
2022-10-11 13:04 ` [Bug tree-optimization/106112] [10/11 " cvs-commit at gcc dot gnu.org
2022-10-14 10:47 ` [Bug tree-optimization/106112] [10 " cvs-commit at gcc dot gnu.org
2022-10-14 10:47 ` rguenth 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).