public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102138] New: t = a==0 and a = PHI<0, t> should be done earlier than PRE
@ 2021-08-30 23:52 pinskia at gcc dot gnu.org
2021-08-30 23:57 ` [Bug tree-optimization/102138] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-30 23:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102138
Bug ID: 102138
Summary: t = a==0 and a = PHI<0, t> should be done earlier than
PRE
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
int len(int f, int l) {
return l < f ? 0 : l - f + 1;
}
int lenzero(int f, int l) {
return len(f, l) == 0;
}
int g(); int h();
int lenzero1(int f, int l) {
if ( len(f, l) == 0)
return g();
return h();
}
we should be able to optimize lenzero at -O1 but don't. lenzero1 is optimized
at -O1 because dom is able to jump thread.
The difference in IR is:
# iftmp.0_9 = PHI <0(2), iftmp.0_8(3)>
_2 = iftmp.0_9 == 0;
vs:
# iftmp.0_13 = PHI <0(2), iftmp.0_12(3)>
if (iftmp.0_13 == 0)
at -O2 PRE is enabled which does the optimization.
This is similar to spaceship_replacement in tree-ssa-phiopt but a more general
statement of the problem.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102138] t = a==0 and a = PHI<0, t> should be done earlier than PRE
2021-08-30 23:52 [Bug tree-optimization/102138] New: t = a==0 and a = PHI<0, t> should be done earlier than PRE pinskia at gcc dot gnu.org
@ 2021-08-30 23:57 ` pinskia at gcc dot gnu.org
2021-08-31 7:34 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-30 23:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102138
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
that is we should be able to optimize lenzero at -O1.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102138] t = a==0 and a = PHI<0, t> should be done earlier than PRE
2021-08-30 23:52 [Bug tree-optimization/102138] New: t = a==0 and a = PHI<0, t> should be done earlier than PRE pinskia at gcc dot gnu.org
2021-08-30 23:57 ` [Bug tree-optimization/102138] " pinskia at gcc dot gnu.org
@ 2021-08-31 7:34 ` rguenth at gcc dot gnu.org
2023-11-02 18:55 ` pinskia at gcc dot gnu.org
2023-11-02 19:00 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-31 7:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102138
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-08-31
Status|UNCONFIRMED |NEW
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. I attached some propagation through PHI folding for forwprop (WIP)
to the spaceship PR. There's also tree-ssa-phiprop.c which does sth like
PHI-translation for loads that could be generalized.
In general it opens the same issues as PRE - possibly extra copies due to the
constants in PHIs and possibly less optimized code because readily available
constants (in registers) are explicitely represented and need to be
re-materialized.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102138] t = a==0 and a = PHI<0, t> should be done earlier than PRE
2021-08-30 23:52 [Bug tree-optimization/102138] New: t = a==0 and a = PHI<0, t> should be done earlier than PRE pinskia at gcc dot gnu.org
2021-08-30 23:57 ` [Bug tree-optimization/102138] " pinskia at gcc dot gnu.org
2021-08-31 7:34 ` rguenth at gcc dot gnu.org
@ 2023-11-02 18:55 ` pinskia at gcc dot gnu.org
2023-11-02 19:00 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-02 18:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102138
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
mine.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102138] t = a==0 and a = PHI<0, t> should be done earlier than PRE
2021-08-30 23:52 [Bug tree-optimization/102138] New: t = a==0 and a = PHI<0, t> should be done earlier than PRE pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2023-11-02 18:55 ` pinskia at gcc dot gnu.org
@ 2023-11-02 19:00 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-02 19:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102138
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is the generic solution to what was done to fix PR 104639.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-02 19:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30 23:52 [Bug tree-optimization/102138] New: t = a==0 and a = PHI<0, t> should be done earlier than PRE pinskia at gcc dot gnu.org
2021-08-30 23:57 ` [Bug tree-optimization/102138] " pinskia at gcc dot gnu.org
2021-08-31 7:34 ` rguenth at gcc dot gnu.org
2023-11-02 18:55 ` pinskia at gcc dot gnu.org
2023-11-02 19:00 ` 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).