public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/35305] Speculative PRE support missing
[not found] <bug-35305-4@http.gcc.gnu.org/bugzilla/>
@ 2012-10-30 18:58 ` xinliangli at gmail dot com
0 siblings, 0 replies; 5+ messages in thread
From: xinliangli at gmail dot com @ 2012-10-30 18:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35305
--- Comment #4 from davidxl <xinliangli at gmail dot com> 2012-10-30 18:57:18 UTC ---
The suggested transformation can be useful in some cases, but won't be general
enough. The listed example is an extreme case. For instance, the second a+b
instance does not have to be in the hot trace but still still hot enough to be
PREed. Or there is no one dominating traces available -- the expression is
available in all incoming paths except for one rare path.
switch (a)
{
case 1:
g[1] = a + b;
break;
case 2:
g[2] = a + b;
break;
case 3:
g[3] = a + b;
...
default:
g[0] = 0;
}
switch (b)
{
case 1:
... a + b; // partially redundant
case 2:
... a + b; // redundant
default:
// does nothing
break;
}
Regarding handling dereferences, the availability and down-safety analysis
needs to be extended to to recognize safe speculation candidates.
Example 1: dereference of same pointer fully available --
int g1, g2;
struct A
{
int a;
int b;
};
void foo(struct A* ap, int k,int m)
{
if (__builtin_expect (k, 1))
g1 = ap->b;
else
g2 = ap->a;
if (__builtin_expect (m, 1))
{
g2 = ap->b; // Good safe speculative PRE candidate
}
}
Example 2: deference of ap fully anticipated
int g1, g2;
struct A
{
int a;
int b;
};
void foo(struct A* ap, int k,int m)
{
if (__builtin_expect (k, 1))
g1 = ap->b;
if (__builtin_expect (m, 1))
g2 = ap->b; // Safe to speculatively hoist across the branch
into the else of the previous branch
else
g1 = ap->a;
}
David
(In reply to comment #3)
> Wouldn't this be a candidate for forming a superblock from hot traces of
> a function? Thus in the testcase
>
> if (k && m)
> {
> g1 = a + b;
> g2 = a + b;
> }
> else
> {
> ... old code
> }
>
> which would also handle the case where we cannot speculatively move code
> (like dereferences)?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/35305] Speculative PRE support missing
2008-02-23 5:15 [Bug middle-end/35305] New: " xinliangli at gmail dot com
` (2 preceding siblings ...)
2009-03-21 0:54 ` steven at gcc dot gnu dot org
@ 2009-03-21 10:53 ` rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-03-21 10:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2009-03-21 10:53 -------
Wouldn't this be a candidate for forming a superblock from hot traces of
a function? Thus in the testcase
if (k && m)
{
g1 = a + b;
g2 = a + b;
}
else
{
... old code
}
which would also handle the case where we cannot speculatively move code
(like dereferences)?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35305
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/35305] Speculative PRE support missing
2008-02-23 5:15 [Bug middle-end/35305] New: " xinliangli at gmail dot com
2008-05-03 0:35 ` [Bug middle-end/35305] " pinskia at gcc dot gnu dot org
2009-02-06 21:53 ` steven at gcc dot gnu dot org
@ 2009-03-21 0:54 ` steven at gcc dot gnu dot org
2009-03-21 10:53 ` rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-03-21 0:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from steven at gcc dot gnu dot org 2009-03-21 00:54 -------
I'm considering implementing/experimenting with something along the lines of
this:
http://www.cs.ualberta.ca/~amaral/cascon/CDP05/slides/CDP05-horspool.pdf
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35305
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/35305] Speculative PRE support missing
2008-02-23 5:15 [Bug middle-end/35305] New: " xinliangli at gmail dot com
2008-05-03 0:35 ` [Bug middle-end/35305] " pinskia at gcc dot gnu dot org
@ 2009-02-06 21:53 ` steven at gcc dot gnu dot org
2009-03-21 0:54 ` steven at gcc dot gnu dot org
2009-03-21 10:53 ` rguenth at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-02-06 21:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from steven at gcc dot gnu dot org 2009-02-06 21:53 -------
Could be added to PPRE.
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dberlin at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-02-06 21:53:02
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35305
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/35305] Speculative PRE support missing
2008-02-23 5:15 [Bug middle-end/35305] New: " xinliangli at gmail dot com
@ 2008-05-03 0:35 ` pinskia at gcc dot gnu dot org
2009-02-06 21:53 ` steven at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-05-03 0:35 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=35305
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-10-30 18:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-35305-4@http.gcc.gnu.org/bugzilla/>
2012-10-30 18:58 ` [Bug middle-end/35305] Speculative PRE support missing xinliangli at gmail dot com
2008-02-23 5:15 [Bug middle-end/35305] New: " xinliangli at gmail dot com
2008-05-03 0:35 ` [Bug middle-end/35305] " pinskia at gcc dot gnu dot org
2009-02-06 21:53 ` steven at gcc dot gnu dot org
2009-03-21 0:54 ` steven at gcc dot gnu dot org
2009-03-21 10:53 ` rguenth at gcc dot gnu dot 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).