public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger
@ 2022-02-19 7:55 zsojka at seznam dot cz
2022-02-19 8:10 ` [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2022-02-19 7:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104604
Bug ID: 104604
Summary: wrong code with -O2 -fconserve-stack
--param=vrp1-mode=ranger
Product: gcc
Version: 12.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 52479
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52479&action=edit
reduced testcase
Output:
$ x86_64-pc-linux-gnu-gcc -O2 -fconserve-stack --param=vrp1-mode=ranger
testcase.c -Wno-psabi
$ ./a.out
Aborted
The value of x[] is {3, 3, 3, 3, ... }
It seems "i /= c;" got optimised out.
$ 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-r12-7293-20220218075854-gfe79d652c96-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.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 --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r12-7293-20220218075854-gfe79d652c96-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220218 (experimental) (GCC)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue
2022-02-19 7:55 [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger zsojka at seznam dot cz
@ 2022-02-19 8:10 ` pinskia at gcc dot gnu.org
2022-02-21 9:44 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-02-19 8:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104604
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |11.2.0
Target Milestone|--- |12.0
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Summary|wrong code with -O2 |[12 Regression]wrong code
|-fconserve-stack |with -O2 VRP Complex
|--param=vrp1-mode=ranger |integer division issue
Last reconfirmed| |2022-02-19
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, reduced testcase which shows the problem even at just -O2:
typedef unsigned char u8;
u8 g;
__attribute__((noipa))
u8 foo (_Complex unsigned c)
{
_Complex unsigned t = 3;
t /= c;
u8 v = g;
return v + t;
}
int
main (void)
{
u8 x = foo (7);
if (x)
__builtin_abort ();
return 0;
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue
2022-02-19 7:55 [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger zsojka at seznam dot cz
2022-02-19 8:10 ` [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue pinskia at gcc dot gnu.org
@ 2022-02-21 9:44 ` rguenth at gcc dot gnu.org
2022-02-21 12:40 ` [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue since r12-3328 jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-02-21 9:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104604
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The EVRP dump with -details isn't very useful, we just see the
folding/substitution phase:
Folding statement: t_5 = __complex__ (3, 0) / c_4(D);
Not folded
Folding statement: v_7 = g;
Not folded
Folding statement: _1 = REALPART_EXPR <t_5>;
Queued stmt for removal. Folds to: 3
and that looks obviously wrong.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue since r12-3328
2022-02-19 7:55 [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger zsojka at seznam dot cz
2022-02-19 8:10 ` [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue pinskia at gcc dot gnu.org
2022-02-21 9:44 ` rguenth at gcc dot gnu.org
@ 2022-02-21 12:40 ` jakub at gcc dot gnu.org
2022-02-21 13:04 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-02-21 12:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104604
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
CC| |jakub at gcc dot gnu.org
Summary|[12 Regression]wrong code |[12 Regression]wrong code
|with -O2 VRP Complex |with -O2 VRP Complex
|integer division issue |integer division issue
| |since r12-3328
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r12-3328-gbccf4b88e184e925ee2d7931e4cf09704f1c3932
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue since r12-3328
2022-02-19 7:55 [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger zsojka at seznam dot cz
` (2 preceding siblings ...)
2022-02-21 12:40 ` [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue since r12-3328 jakub at gcc dot gnu.org
@ 2022-02-21 13:04 ` jakub at gcc dot gnu.org
2022-02-22 9:43 ` cvs-commit at gcc dot gnu.org
2022-02-22 9:56 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-02-21 13:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104604
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 #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 52483
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52483&action=edit
gcc12-pr104604.patch
Untested fix.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue since r12-3328
2022-02-19 7:55 [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger zsojka at seznam dot cz
` (3 preceding siblings ...)
2022-02-21 13:04 ` jakub at gcc dot gnu.org
@ 2022-02-22 9:43 ` cvs-commit at gcc dot gnu.org
2022-02-22 9:56 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-22 9:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104604
--- 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:d44dc131f48254fccc69ec4178fec030e0e2761d
commit r12-7324-gd44dc131f48254fccc69ec4178fec030e0e2761d
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Feb 22 10:43:13 2022 +0100
ranger: Fix up REALPART_EXPR/IMAGPART_EXPR handling [PR104604]
The following testcase is miscompiled since r12-3328.
That change assumed that if rhs1 of a GIMPLE_ASSIGN is COMPLEX_CST, then
that is the value of the lhs of the stmt, but that is not the case always,
only if it is a GIMPLE_SINGLE_RHS stmt. If it is e.g.
GIMPLE_UNARY_RHS or GIMPLE_BINARY_RHS (the latter happens in the testcase),
then it can be e.g.
__complex__ (3, 0) / var
and the REALPART_EXPR of that isn't 3, but the realpart of the division.
I assume once the ranger can do complex numbers adjust_*part_expr will just
fetch one or the other range from a underlying complex range, but until
then, we should limit this to what r12-3328 meant to do.
2022-02-22 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/104604
* gimple-range-fold.cc (adjust_imagpart_expr,
adjust_realpart_expr):
Only check if gimple_assign_rhs1 is COMPLEX_CST if
gimple_assign_rhs_code is COMPLEX_CST.
* gcc.c-torture/execute/pr104604.c: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue since r12-3328
2022-02-19 7:55 [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger zsojka at seznam dot cz
` (4 preceding siblings ...)
2022-02-22 9:43 ` cvs-commit at gcc dot gnu.org
@ 2022-02-22 9:56 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-02-22 9:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104604
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-02-22 9:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-19 7:55 [Bug tree-optimization/104604] New: wrong code with -O2 -fconserve-stack --param=vrp1-mode=ranger zsojka at seznam dot cz
2022-02-19 8:10 ` [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue pinskia at gcc dot gnu.org
2022-02-21 9:44 ` rguenth at gcc dot gnu.org
2022-02-21 12:40 ` [Bug tree-optimization/104604] [12 Regression]wrong code with -O2 VRP Complex integer division issue since r12-3328 jakub at gcc dot gnu.org
2022-02-21 13:04 ` jakub at gcc dot gnu.org
2022-02-22 9:43 ` cvs-commit at gcc dot gnu.org
2022-02-22 9:56 ` 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).