public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113434] New: [13/14 Regression] Missed optimization for Loop Unswitch
@ 2024-01-17 3:10 652023330028 at smail dot nju.edu.cn
2024-01-17 3:16 ` [Bug tree-optimization/113434] [13/14 Regression] VRP misses conditional in loop is always false sometimes pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: 652023330028 at smail dot nju.edu.cn @ 2024-01-17 3:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113434
Bug ID: 113434
Summary: [13/14 Regression] Missed optimization for Loop
Unswitch
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: 652023330028 at smail dot nju.edu.cn
Target Milestone: ---
Hello, we noticed that maybe there is a missed optimization for Loop Unswitch.
In the following code, if(a) is actually always true.
https://godbolt.org/z/rr5M77sEG
int a, b;
void test() {
a = 0;
for (int c = 0; c < 100; c += 1) {
a += 2;
if (a)
b += 3;
}
}
But GCC (trunk) -O3 -fwrapv:
test():
mov edx, DWORD PTR b[rip]
mov eax, 2
.L3:
test eax, eax
jne .L2
mov eax, 2
.L2:
add eax, 2
add edx, 3
cmp eax, 202
jne .L3
mov DWORD PTR a[rip], 200
mov DWORD PTR b[rip], edx
ret
Expected code (GCC-12.3 -O3 -fwrapv):
test():
mov edx, DWORD PTR b[rip]
xor eax, eax
.L2:
add eax, 2
add edx, 3
cmp eax, 200
jne .L2
mov DWORD PTR a[rip], 200
mov DWORD PTR b[rip], edx
ret
Thank you very much for your time and effort! We look forward to hearing from
you.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/113434] [13/14 Regression] VRP misses conditional in loop is always false sometimes
2024-01-17 3:10 [Bug tree-optimization/113434] New: [13/14 Regression] Missed optimization for Loop Unswitch 652023330028 at smail dot nju.edu.cn
@ 2024-01-17 3:16 ` pinskia at gcc dot gnu.org
2024-01-17 8:17 ` rguenth at gcc dot gnu.org
2024-05-21 9:18 ` [Bug tree-optimization/113434] [13/14/15 " jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-17 3:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113434
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Target Milestone|--- |13.3
Last reconfirmed| |2024-01-17
Ever confirmed|0 |1
Summary|[13/14 Regression] Missed |[13/14 Regression] VRP
|optimization for Loop |misses conditional in loop
|Unswitch |is always false sometimes
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. Note it is not loop switching but rather VRP which should have
figured out a bounds are [2,202] inside the loop but for some reason it is not
able to.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/113434] [13/14 Regression] VRP misses conditional in loop is always false sometimes
2024-01-17 3:10 [Bug tree-optimization/113434] New: [13/14 Regression] Missed optimization for Loop Unswitch 652023330028 at smail dot nju.edu.cn
2024-01-17 3:16 ` [Bug tree-optimization/113434] [13/14 Regression] VRP misses conditional in loop is always false sometimes pinskia at gcc dot gnu.org
@ 2024-01-17 8:17 ` rguenth at gcc dot gnu.org
2024-05-21 9:18 ` [Bug tree-optimization/113434] [13/14/15 " jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-17 8:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113434
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
Priority|P3 |P2
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
It needs LIM (store-motion) to make 'a' a register inside the loop but that
runs after VRP1, the next VRP only runs after SCCP and also IVOPTs which
confuses it. With -fno-ivopts it's OK but still too late for SCCP.
Thus, a pass ordering issue between LIM / VRP and a missed VRP after IVOPTs
obfuscation.
We might want to consider doing store-motion even earlier ...
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/113434] [13/14/15 Regression] VRP misses conditional in loop is always false sometimes
2024-01-17 3:10 [Bug tree-optimization/113434] New: [13/14 Regression] Missed optimization for Loop Unswitch 652023330028 at smail dot nju.edu.cn
2024-01-17 3:16 ` [Bug tree-optimization/113434] [13/14 Regression] VRP misses conditional in loop is always false sometimes pinskia at gcc dot gnu.org
2024-01-17 8:17 ` rguenth at gcc dot gnu.org
@ 2024-05-21 9:18 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-05-21 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113434
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.3 |13.4
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 13.3 is being released, retargeting bugs to GCC 13.4.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-21 9:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17 3:10 [Bug tree-optimization/113434] New: [13/14 Regression] Missed optimization for Loop Unswitch 652023330028 at smail dot nju.edu.cn
2024-01-17 3:16 ` [Bug tree-optimization/113434] [13/14 Regression] VRP misses conditional in loop is always false sometimes pinskia at gcc dot gnu.org
2024-01-17 8:17 ` rguenth at gcc dot gnu.org
2024-05-21 9:18 ` [Bug tree-optimization/113434] [13/14/15 " 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).