public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/29333] New: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt
@ 2006-10-03 16:04 roberto dot costa at st dot com
2006-10-03 16:05 ` [Bug tree-optimization/29333] " roberto dot costa at st dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: roberto dot costa at st dot com @ 2006-10-03 16:04 UTC (permalink / raw)
To: gcc-bugs
There are cases in which phiopt doesn't recognize MAX_EXPRs or MIN_EXPRs
patterns.
In particular, source codes that look very similar at first sight may induce
phiopt to behave differently.
Let's consider the following two functions:
-----------------------------
int minmax_correct(int a)
{
if (a > 32767) a = 32767;
else if (a < -32768) a = -32768;
return a;
}
int minmax_wrong(int a)
{
if (a > 32767) a = 32767;
if (a < -32768) a = -32768;
return a;
}
-----------------------------
MIN_EXPRs and MAX_EXPRs are generated for the first function, but not for the
second.
Here is the contents of trace file minmax.c.042t.phicprop1:
-----------------------------
;; Function minmax_correct (minmax_correct)
minmax_correct (a)
{
<bb 2>:
if (a_2 > 32767) goto <L3>; else goto <L1>;
<L1>:;
if (a_2 < -32768) goto <L2>; else goto <L3>;
<L2>:;
# a_1 = PHI <32767(2), a_2(3), -32768(4)>;
<L3>:;
<retval> = a_1;
return <retval>;
}
;; Function minmax_wrong (minmax_wrong)
Removing basic block 6
minmax_wrong (a)
{
<bb 2>:
if (a_3 > 32767) goto <L6>; else goto <L1>;
<L1>:;
if (a_3 < -32768) goto <L3>; else goto <L6>;
# a_9 = PHI <a_3(3), 32767(2)>;
<L6>:;
# a_2 = PHI <a_9(4), -32768(3)>;
<L3>:;
<retval> = a_2;
return <retval>;
}
-----------------------------
And here is minmax.c.043t.phiopt1:
-----------------------------
;; Function minmax_correct (minmax_correct)
Removing basic block 4
Removing basic block 3
Merging blocks 2 and 5
minmax_correct (a)
{
<bb 2>:
a_7 = MAX_EXPR <-32768, a_2>;
a_8 = MIN_EXPR <a_7, 32767>;
<retval> = a_8;
return <retval>;
}
;; Function minmax_wrong (minmax_wrong)
minmax_wrong (a)
{
<bb 2>:
if (a_3 > 32767) goto <L6>; else goto <L1>;
<L1>:;
if (a_3 < -32768) goto <L3>; else goto <L6>;
# a_9 = PHI <a_3(3), 32767(2)>;
<L6>:;
# a_2 = PHI <a_9(4), -32768(3)>;
<L3>:;
<retval> = a_2;
return <retval>;
}
-----------------------------
--
Summary: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: roberto dot costa at st dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29333
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/29333] Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt
2006-10-03 16:04 [Bug tree-optimization/29333] New: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt roberto dot costa at st dot com
@ 2006-10-03 16:05 ` roberto dot costa at st dot com
2006-10-03 16:06 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: roberto dot costa at st dot com @ 2006-10-03 16:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from roberto dot costa at st dot com 2006-10-03 16:05 -------
Created an attachment (id=12378)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12378&action=view)
Source code of the example
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29333
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/29333] Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt
2006-10-03 16:04 [Bug tree-optimization/29333] New: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt roberto dot costa at st dot com
2006-10-03 16:05 ` [Bug tree-optimization/29333] " roberto dot costa at st dot com
@ 2006-10-03 16:06 ` pinskia at gcc dot gnu dot org
2006-10-03 16:11 ` [Bug tree-optimization/29333] Jump threading getting in the way of PHI-OPT pinskia at gcc dot gnu dot org
2006-10-05 8:15 ` roberto dot costa at st dot com
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-03 16:06 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Keywords| |missed-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29333
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/29333] Jump threading getting in the way of PHI-OPT
2006-10-03 16:04 [Bug tree-optimization/29333] New: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt roberto dot costa at st dot com
2006-10-03 16:05 ` [Bug tree-optimization/29333] " roberto dot costa at st dot com
2006-10-03 16:06 ` pinskia at gcc dot gnu dot org
@ 2006-10-03 16:11 ` pinskia at gcc dot gnu dot org
2006-10-05 8:15 ` roberto dot costa at st dot com
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-03 16:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-10-03 16:11 -------
Actually this is a case where jump threading gets in the way of PHI-OPT.
Really PHI-OPT should be put before VRP and DOM, I don't know why it was not.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-10-03 16:11:22
date| |
Summary|Generation of MAX_EXPRs and |Jump threading getting in
|MIN_EXPRs missed by phiopt |the way of PHI-OPT
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29333
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/29333] Jump threading getting in the way of PHI-OPT
2006-10-03 16:04 [Bug tree-optimization/29333] New: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt roberto dot costa at st dot com
` (2 preceding siblings ...)
2006-10-03 16:11 ` [Bug tree-optimization/29333] Jump threading getting in the way of PHI-OPT pinskia at gcc dot gnu dot org
@ 2006-10-05 8:15 ` roberto dot costa at st dot com
3 siblings, 0 replies; 5+ messages in thread
From: roberto dot costa at st dot com @ 2006-10-05 8:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from roberto dot costa at st dot com 2006-10-05 08:15 -------
I tested what happens if the first PHI-OPT pass is moved right before the first
VRP pass in gcc/passes.c
It looks like PHI-OPT should be run both before and after VRP and DOM.
The example reported shows that, when PHI-OPT is run after VRP and DOM, it
misses some MAX_EXPR and MIN_EXPR generation.
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-5.c shows that, when PHI-OPT anticipates
VRP and DOM, it misses some MAX_EXPR and MIN_EXPR generation as well.
Should an additional PHI-OPT pass be added before VRP and DOM?
(In this case, a few testsuite examples should also be changed in order to
consider what happens after PHI-OPT2 instead of PHI-OPT1)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29333
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-10-05 8:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-03 16:04 [Bug tree-optimization/29333] New: Generation of MAX_EXPRs and MIN_EXPRs missed by phiopt roberto dot costa at st dot com
2006-10-03 16:05 ` [Bug tree-optimization/29333] " roberto dot costa at st dot com
2006-10-03 16:06 ` pinskia at gcc dot gnu dot org
2006-10-03 16:11 ` [Bug tree-optimization/29333] Jump threading getting in the way of PHI-OPT pinskia at gcc dot gnu dot org
2006-10-05 8:15 ` roberto dot costa at st 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).