public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP
@ 2020-11-24 7:47 ishiura-compiler at ml dot kwansei.ac.jp
2020-11-24 8:06 ` [Bug tree-optimization/97964] " pinskia at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: ishiura-compiler at ml dot kwansei.ac.jp @ 2020-11-24 7:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
Bug ID: 97964
Summary: Missed optimization opportunity for VRP
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ishiura-compiler at ml dot kwansei.ac.jp
Target Milestone: ---
We compiled two programs (A1.c, A2.c) by gcc-10.2.0 with -O3 option.
The two programs are equivalent, but resulted in different assembly codes.
Although varialbe a is volatile, the value of variable t can be
determined at compile time via VRP optimization.
Note that gcc-7.5.0 or older versions compiled the both code into the
same minimum assebmly codes. For more precise:
gcc-10.2.0 diff
gcc-9.3.0 diff
gcc-8.0.1 diff
gcc-7.5.0 OK
gcc-6.5.0 OK
gcc-5.5.0 OK
+---------------------------------+---------------------------------+
| A1.c | A2.c |
+---------------------------------+---------------------------------+
|int main (void) |int main (void) |
|{ |{ |
| volatile int a = -1; | volatile int a = 1; |
| long b = -2; | |
| | |
| int c = a>0; | |
| int d = b*c; | |
| int e = 1-d; | a; |
| int t = (-1/(int)e)==1; | int t = 0; |
| | |
| if (t != 0) __builtin_abort(); | if (t != 0) __builtin_abort(); |
| | |
| return 0; | return 0; |
|} |} |
+---------------------------------+---------------------------------+
gcc-10.2.0
+-------------------------------+------------------------------+
| A1.s (gcc-10.2.0 A1.c -O3 -S) | A2.s (gcc-10.2.0 A2.c -O3 -S)|
+-------------------------------+------------------------------+
|main: |main: |
|.LFB0: |.LFB0: |
| .cfi_startproc | .cfi_startproc |
| subq $24, %rsp | movl $1, -4(%rsp) |
| .cfi_def_cfa_offset 32 | movl -4(%rsp), %eax |
| movl $1, 12(%ecx) | |
| movl $-1, 12(%rsp) | |
| movl 12(%rsp), %eax | |
| testl %eax, %eax | |
| setle %al | |
| movzbl %al, %eax | |
| leal -2(%rax,%rax), %eax | |
| subl %eax, %ecx | |
| movl $-1, %eax | |
| cltd | |
| idiv %ecx | |
| cmpl $1, %eax | |
| je .L3 | |
| xorl %eax, %eax | xorl %eax, %eax |
| addq $24, %rsp | |
| .cfi_def_cfa_offset 8 | |
| ret | ret |
| .cfi_endproc | .cfi_endproc |
| .section .text.unlikely | |
| .cfi_startproc | |
| .type main.cold, @function| |
|main.cold: | |
|.LFSB0: | |
|.L3: | |
| .cfi_def_cfa_offset 32 | |
| call abort | |
| .cfi_endproc | |
|.LFE0: |.LFE0: |
| .section text.startup | |
| .size main, .-main | .size main, .-main |
| .section .text.unlikely | |
| .size main.cold, .-mai...| |
|.LCOLDE0: | |
| .section .text.startup | |
|.LHOTE0: | |
| .ident "GCC:(GNU) 10.2.0" | .ident "GCC:(GNU) 10.2.0" |
| .section .note.GNU-stac...| .section .note.GNU-stac...|
+--------------------------------------------------------------+
gcc-7.5.0
+-------------------------------+------------------------------+
| A1.s (gcc-7.5.0 A1.c -O3 -S) | A2.s (gcc-7.5.0 A2.c -O3 -S) |
+-------------------------------+------------------------------+
|main: |main: |
|.LFB0: |.LFB0: |
| .cfi_startproc | .cfi_startproc |
| movl $1, -4(%rsp) | movl $1, -4(%rsp) |
| movl -4(%rsp), %eax | movl -4(%rsp), %eax |
| xorl %eax, %eax | xorl %eax, %eax |
| ret | ret |
| .cfi_endproc | .cfi_endproc |
|.LFE0: |.LFE0: |
| .size main, .-main | .size main, .-main |
| .ident "GCC:(Ubuntu 7.5...| .ident "GCC:(Ubuntu 7.5...|
| .section .note.GNU-stac...| .section .note.GNU-stac...|
+--------------------------------------------------------------+
$ gcc -v
using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
target: x86_64-pc-linux-gnu
configure woth: ../configure --enable-languages=c,c++ --prefix=/usr/local
--disable-bootstrap --disable-multilib
thred model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
$ gcc-7 -v
Using built-in specs.
COLLECT_GCC=gcc-7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.5.0-3ubuntu1~18.04'
--with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu-
--enable-shared --enable-linker-build-id --libexecdir=/usr/lib
--without-included-gettext
--enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify
--enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib --enable-objc-gc=auto --enable-multiarch
--disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib
--with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
@ 2020-11-24 8:06 ` pinskia at gcc dot gnu.org
2020-11-24 8:27 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-11-24 8:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here are the ranges that should be figured out:
c:[0,1]
d:[-2,0]
e:[0,2]
The problem comes from the fact -1/e could be undefined.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
2020-11-24 8:06 ` [Bug tree-optimization/97964] " pinskia at gcc dot gnu.org
@ 2020-11-24 8:27 ` rguenth at gcc dot gnu.org
2020-11-24 9:32 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-24 8:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
Blocks| |85316
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
possibly caused by a bugfix
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
2020-11-24 8:06 ` [Bug tree-optimization/97964] " pinskia at gcc dot gnu.org
2020-11-24 8:27 ` rguenth at gcc dot gnu.org
@ 2020-11-24 9:32 ` jakub at gcc dot gnu.org
2020-11-24 9:38 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-24 9:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Keywords|needs-bisection |
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Changed with r8-2090-g2071f8f980cc0de02af3d7d7de201f4f189058ff
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
` (2 preceding siblings ...)
2020-11-24 9:32 ` jakub at gcc dot gnu.org
@ 2020-11-24 9:38 ` jakub at gcc dot gnu.org
2020-11-24 9:39 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-24 9:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note, trunk handles it fine again starting with
r11-4755-g22984f3f090921b5ac80ec0057f6754ec458e97e
So I guess we should just add the testcase (perhaps use a parameter instead of
volatile etc.) and close, ranger is not backportable and even smaller VRP
improvements might be too risky.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
` (3 preceding siblings ...)
2020-11-24 9:38 ` jakub at gcc dot gnu.org
@ 2020-11-24 9:39 ` rguenth at gcc dot gnu.org
2020-11-24 9:44 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-24 9:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> Note, trunk handles it fine again starting with
> r11-4755-g22984f3f090921b5ac80ec0057f6754ec458e97e
> So I guess we should just add the testcase (perhaps use a parameter instead
> of volatile etc.) and close, ranger is not backportable and even smaller VRP
> improvements might be too risky.
Agreed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
` (4 preceding siblings ...)
2020-11-24 9:39 ` rguenth at gcc dot gnu.org
@ 2020-11-24 9:44 ` cvs-commit at gcc dot gnu.org
2020-11-24 9:51 ` jakub at gcc dot gnu.org
2021-08-14 22:29 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-24 9:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
--- Comment #6 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:a40d5772ff12a3a4f4830b7db27bedf54b617e8e
commit r11-5277-ga40d5772ff12a3a4f4830b7db27bedf54b617e8e
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Nov 24 10:42:56 2020 +0100
testsuite: Add testcase for already fixed bug [PR97964]
This testcase started failing with r8-2090 and works again starting
with r11-4755.
2020-11-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/97964
* gcc.dg/tree-ssa/pr97964.c: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
` (5 preceding siblings ...)
2020-11-24 9:44 ` cvs-commit at gcc dot gnu.org
@ 2020-11-24 9:51 ` jakub at gcc dot gnu.org
2021-08-14 22:29 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-24 9:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Thus fixed for 11.1+.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/97964] Missed optimization opportunity for VRP
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
` (6 preceding siblings ...)
2020-11-24 9:51 ` jakub at gcc dot gnu.org
@ 2021-08-14 22:29 ` pinskia at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-14 22:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97964
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-08-14 22:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 7:47 [Bug tree-optimization/97964] New: Missed optimization opportunity for VRP ishiura-compiler at ml dot kwansei.ac.jp
2020-11-24 8:06 ` [Bug tree-optimization/97964] " pinskia at gcc dot gnu.org
2020-11-24 8:27 ` rguenth at gcc dot gnu.org
2020-11-24 9:32 ` jakub at gcc dot gnu.org
2020-11-24 9:38 ` jakub at gcc dot gnu.org
2020-11-24 9:39 ` rguenth at gcc dot gnu.org
2020-11-24 9:44 ` cvs-commit at gcc dot gnu.org
2020-11-24 9:51 ` jakub at gcc dot gnu.org
2021-08-14 22:29 ` 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).