public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
@ 2020-10-21 15:23 suochenyao at 163 dot com
2020-10-21 18:26 ` [Bug tree-optimization/97520] " amacleod at redhat dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: suochenyao at 163 dot com @ 2020-10-21 15:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
Bug ID: 97520
Summary: ICE in calc_stmt, at gimple-range.cc:399 with "-O1
-fno-tree-fre -ftree-vrp"
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: suochenyao at 163 dot com
Target Milestone: ---
*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
char a;
void b() {
char *c[5];
char *d = &a;
&d;
*(c[4] = d);
}
int main() { return 0; }
*******************************************************************************
gcc version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/suocy/bin/gcc-dev/bin/gcc
COLLECT_LTO_WRAPPER=/home/suocy/bin/gcc-dev/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/suocy/bin/gcc-dev
--disable-multilib --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201020 (experimental) (GCC)
*******************************************************************************
Command Lines:
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -O1 -fno-tree-fre -ftree-vrp
a.c
a.c: In function ‘b’:
a.c:5:3: warning: statement with no effect [-Wunused-value]
5 | &d;
| ^~
a.c:6:3: warning: value computed is not used [-Wunused-value]
6 | *(c[4] = d);
| ^~~~~~~~~~~
during GIMPLE pass: evrp
a.c:8:1: internal compiler error: in calc_stmt, at gimple-range.cc:399
8 | int main() { return 0; }
| ^~~
0x7f6095 gimple_ranger::calc_stmt(irange&, gimple*, tree_node*)
../../gcc/gimple-range.cc:399
0x188dc5f gimple_ranger::range_of_stmt(irange&, gimple*, tree_node*)
../../gcc/gimple-range.cc:992
0x188a498 gimple_ranger::range_of_expr(irange&, tree_node*, gimple*)
../../gcc/gimple-range.cc:883
0x10a236d range_query::value_of_expr(tree_node*, gimple*)
../../gcc/value-query.cc:85
0x172bc71 hybrid_folder::value_of_expr(tree_node*, gimple*)
../../gcc/gimple-ssa-evrp.c:235
0xf5c73e substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
../../gcc/tree-ssa-propagate.c:1112
0x1703777 dom_walker::walk(basic_block_def*)
../../gcc/domwalk.c:309
0xf5b955 substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
../../gcc/tree-ssa-propagate.c:1283
0x172b8e6 execute_early_vrp
../../gcc/gimple-ssa-evrp.c:349
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/97520] ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
@ 2020-10-21 18:26 ` amacleod at redhat dot com
2020-10-21 18:34 ` marxin at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2020-10-21 18:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
Andrew Macleod <amacleod at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amacleod at redhat dot com
--- Comment #1 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 49416
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49416&action=edit
handle a_2 = &a
We handle more complex memory processing like &(x_2 +1), but the very simple
a_2 = &a_1
was slipping thru and we were creating the range based on a_1, not &a_1.
Typically we never saw that since earlier passes were propagating this.
turning off FRE exposed this situatuion.
This patch should correct that... verifying now.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/97520] ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
2020-10-21 18:26 ` [Bug tree-optimization/97520] " amacleod at redhat dot com
@ 2020-10-21 18:34 ` marxin at gcc dot gnu.org
2020-10-21 18:35 ` marxin at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-21 18:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-10-21
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC| |marxin at gcc dot gnu.org
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Just for the record, started with r11-4080-g6e02de946125c368.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/97520] ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
2020-10-21 18:26 ` [Bug tree-optimization/97520] " amacleod at redhat dot com
2020-10-21 18:34 ` marxin at gcc dot gnu.org
@ 2020-10-21 18:35 ` marxin at gcc dot gnu.org
2020-10-22 0:16 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-21 18:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |11.0
Target Milestone|--- |11.0
Known to work| |10.2.0
Priority|P3 |P1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/97520] ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
` (2 preceding siblings ...)
2020-10-21 18:35 ` marxin at gcc dot gnu.org
@ 2020-10-22 0:16 ` cvs-commit at gcc dot gnu.org
2020-10-22 7:03 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-22 0:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Macleod <amacleod@gcc.gnu.org>:
https://gcc.gnu.org/g:966fdb2e12c0347aa3f9efaf5f4e1cd8237fa024
commit r11-4200-g966fdb2e12c0347aa3f9efaf5f4e1cd8237fa024
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Wed Oct 21 20:11:16 2020 -0400
Handle a_2= &b properly in range calculations.
when processing assignments, we were using the type of b instead of type
of &b when computing a range. This was usually filtered out by FRE.
turning it off exposed it.
gcc/
PR tree-optimization/97520
* gimple-range.cc (range_of_non_trivial_assignment): Handle x = &a
by returning a non-zero range.
gcc/testsuite/
* gcc.dg/pr97520.c: New.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/97520] ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
` (3 preceding siblings ...)
2020-10-22 0:16 ` cvs-commit at gcc dot gnu.org
@ 2020-10-22 7:03 ` rguenth at gcc dot gnu.org
2020-10-30 15:25 ` suochenyao at 163 dot com
2020-10-30 15:27 ` suochenyao at 163 dot com
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-22 7:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/97520] ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
` (4 preceding siblings ...)
2020-10-22 7:03 ` rguenth at gcc dot gnu.org
@ 2020-10-30 15:25 ` suochenyao at 163 dot com
2020-10-30 15:27 ` suochenyao at 163 dot com
6 siblings, 0 replies; 8+ messages in thread
From: suochenyao at 163 dot com @ 2020-10-30 15:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
--- Comment #5 from suochenyao at 163 dot com <suochenyao at 163 dot com> ---
*******************************************************************************
I think this can be reproduced with "-fno-strict-aliasing"...
I am not sure whether it can be helpful...
*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
int printf(const char *, ...);
union {
long a;
int b;
} c;
int d=0;
long e=0;
long *f = &c.a;
short g=0;
int *h = &c.b;
short i(int j) {
g = *h;
*f = 3;
for (;; e--) {
if (*h)
return d;
*h = j;
}
return 0;
}
int main() {
i(1);
printf("%d\n", (int)e);
return 0;
}
*******************************************************************************
gcc version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/suocy/bin/gcc-dev/bin/gcc
COLLECT_LTO_WRAPPER=/home/suocy/bin/gcc-dev/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/suocy/bin/gcc-dev/
--disable-multilib --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201029 (experimental) (GCC)
*******************************************************************************
Command Lines:
$ gcc a.c -o a.o1
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -Og -fgcse -fstrict-aliasing
a.c -o a.o2
$ gcc -Og -fgcse -fstrict-aliasing a.c -o a.o3
$ ./a.o1
0
$ ./a.o2
-1
$ ./a.o3
-1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug tree-optimization/97520] ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp"
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
` (5 preceding siblings ...)
2020-10-30 15:25 ` suochenyao at 163 dot com
@ 2020-10-30 15:27 ` suochenyao at 163 dot com
6 siblings, 0 replies; 8+ messages in thread
From: suochenyao at 163 dot com @ 2020-10-30 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97520
--- Comment #6 from suochenyao at 163 dot com <suochenyao at 163 dot com> ---
(In reply to suochenyao@163.com from comment #5)
> *****************************************************************************
> **
> I think this can be reproduced with "-fno-strict-aliasing"...
> I am not sure whether it can be helpful...
> *****************************************************************************
> **
> OS and Platform:
> CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
> *****************************************************************************
> **
> Program:
> int printf(const char *, ...);
> union {
> long a;
> int b;
> } c;
> int d=0;
> long e=0;
> long *f = &c.a;
> short g=0;
> int *h = &c.b;
> short i(int j) {
> g = *h;
> *f = 3;
> for (;; e--) {
> if (*h)
> return d;
> *h = j;
> }
> return 0;
> }
> int main() {
> i(1);
> printf("%d\n", (int)e);
> return 0;
> }
> *****************************************************************************
> **
> gcc version:
> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=/home/suocy/bin/gcc-dev/bin/gcc
> COLLECT_LTO_WRAPPER=/home/suocy/bin/gcc-dev/libexec/gcc/x86_64-pc-linux-gnu/
> 11.0.0/lto-wrapper
> Target: x86_64-pc-linux-gnu
> Configured with: ../configure --prefix=/home/suocy/bin/gcc-dev/
> --disable-multilib --enable-languages=c,c++
> Thread model: posix
> Supported LTO compression algorithms: zlib
> gcc version 11.0.0 20201029 (experimental) (GCC)
> *****************************************************************************
> **
> Command Lines:
> $ gcc a.c -o a.o1
> $ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -Og -fgcse
> -fstrict-aliasing a.c -o a.o2
> $ gcc -Og -fgcse -fstrict-aliasing a.c -o a.o3
> $ ./a.o1
> 0
> $ ./a.o2
> -1
> $ ./a.o3
> -1
Sorry, comment to the wrong place...
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-10-30 15:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21 15:23 [Bug c/97520] New: ICE in calc_stmt, at gimple-range.cc:399 with "-O1 -fno-tree-fre -ftree-vrp" suochenyao at 163 dot com
2020-10-21 18:26 ` [Bug tree-optimization/97520] " amacleod at redhat dot com
2020-10-21 18:34 ` marxin at gcc dot gnu.org
2020-10-21 18:35 ` marxin at gcc dot gnu.org
2020-10-22 0:16 ` cvs-commit at gcc dot gnu.org
2020-10-22 7:03 ` rguenth at gcc dot gnu.org
2020-10-30 15:25 ` suochenyao at 163 dot com
2020-10-30 15:27 ` suochenyao at 163 dot com
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).