public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/23455] New: load PRE is missing
@ 2005-08-18  8:22 bonzini at gcc dot gnu dot org
  2005-08-18 11:47 ` [Bug tree-optimization/23455] " bonzini at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2005-08-18  8:22 UTC (permalink / raw)
  To: gcc-bugs

Load PRE is scheduled for 4.2, I'm creating this bug because load PRE is
currently split between CSE and GCSE (this bug blocks the "optimizations caught
by CSE" meta-bug, PR19721).  Given this code,

   unsigned outcnt;
   extern void flush_outbuf(void);

   void
   bi_windup(unsigned char *outbuf, unsigned char bi_buf)
   {
       outbuf[outcnt] = bi_buf;
       if (outcnt == 16384)
               flush_outbuf();
       outbuf[outcnt] = bi_buf;
   }
   
we'd want the code to become

    void
    bi_windup(unsigned char *outbuf, unsigned char bi_buf)
    {
        int t1 = outcnt;
        outbuf[t1] = bi_buf;
        int t2 = outcnt, t3;
        if (t2 == 16384) {
                flush_outbuf();
		t3 = outcnt;
	} else
		t3 = t2;
        outbuf[t3] = bi_buf;
    }

currently this optimization is split between CSE (with path following) and GCSE.  
Actually, GCSE is able to do it alone if the number of GCSE passes is increased.

-- 
           Summary: load PRE is missing
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bonzini at gcc dot gnu dot org
                CC: dberlin at gcc dot gnu dot org,gcc-bugs at gcc dot gnu
                    dot org
OtherBugsDependingO 19721
             nThis:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23455


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/23455] load PRE is missing
  2005-08-18  8:22 [Bug tree-optimization/23455] New: load PRE is missing bonzini at gcc dot gnu dot org
@ 2005-08-18 11:47 ` bonzini at gcc dot gnu dot org
  2005-08-18 13:15 ` dberlin at dberlin dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2005-08-18 11:47 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-18 11:44:20
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23455


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/23455] load PRE is missing
  2005-08-18  8:22 [Bug tree-optimization/23455] New: load PRE is missing bonzini at gcc dot gnu dot org
  2005-08-18 11:47 ` [Bug tree-optimization/23455] " bonzini at gcc dot gnu dot org
@ 2005-08-18 13:15 ` dberlin at dberlin dot org
  2005-08-18 13:46 ` bonzini at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dberlin at dberlin dot org @ 2005-08-18 13:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dberlin at gcc dot gnu dot org  2005-08-18 13:09 -------
Subject: Re:  New: load PRE is missing

On Thu, 2005-08-18 at 07:55 +0000, bonzini at gcc dot gnu dot org wrote:
> Load PRE is scheduled for 4.2, I'm creating this bug because load PRE is
> currently split between CSE and GCSE (this bug blocks the "optimizations caught
> by CSE" meta-bug, PR19721).  Given this code,
> 
>    unsigned outcnt;
>    extern void flush_outbuf(void);
> 
>    void
>    bi_windup(unsigned char *outbuf, unsigned char bi_buf)
>    {
>        outbuf[outcnt] = bi_buf;
>        if (outcnt == 16384)
>                flush_outbuf();
>        outbuf[outcnt] = bi_buf;
>    }
>    
> we'd want the code to become
> 
>     void
>     bi_windup(unsigned char *outbuf, unsigned char bi_buf)
>     {
>         int t1 = outcnt;
>         outbuf[t1] = bi_buf;
>         int t2 = outcnt, t3;
>         if (t2 == 16384) {
>                 flush_outbuf();
> 		t3 = outcnt;
> 	} else
> 		t3 = t2;
>         outbuf[t3] = bi_buf;
>     }
> 

This doesn't remove a single load.
In fact, i'm not sure what you think is better about this code.

However, it certainly won't be caught by load PRE.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23455


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/23455] load PRE is missing
  2005-08-18  8:22 [Bug tree-optimization/23455] New: load PRE is missing bonzini at gcc dot gnu dot org
  2005-08-18 11:47 ` [Bug tree-optimization/23455] " bonzini at gcc dot gnu dot org
  2005-08-18 13:15 ` dberlin at dberlin dot org
@ 2005-08-18 13:46 ` bonzini at gcc dot gnu dot org
  2005-08-18 13:47 ` dberlin at dberlin dot org
  2005-08-18 13:52 ` bonzini at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2005-08-18 13:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bonzini at gcc dot gnu dot org  2005-08-18 13:44 -------
outcnt aliases with outbuf

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23455


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/23455] load PRE is missing
  2005-08-18  8:22 [Bug tree-optimization/23455] New: load PRE is missing bonzini at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-08-18 13:46 ` bonzini at gcc dot gnu dot org
@ 2005-08-18 13:47 ` dberlin at dberlin dot org
  2005-08-18 13:52 ` bonzini at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: dberlin at dberlin dot org @ 2005-08-18 13:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dberlin at gcc dot gnu dot org  2005-08-18 13:46 -------
Subject: Re:  load PRE is missing

On Thu, 2005-08-18 at 13:44 +0000, bonzini at gcc dot gnu dot org wrote:
> ------- Additional Comments From bonzini at gcc dot gnu dot org  2005-08-18 13:44 -------
> outcnt aliases with outbuf
> 

Then there is nothing to optimize in this testcase.

If you look at the code you want, you have exactly the same number of
loads from the global along the main path, and have actually *added* an
extra load along the other path.

This is *not* an optimization.




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23455


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug tree-optimization/23455] load PRE is missing
  2005-08-18  8:22 [Bug tree-optimization/23455] New: load PRE is missing bonzini at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2005-08-18 13:47 ` dberlin at dberlin dot org
@ 2005-08-18 13:52 ` bonzini at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2005-08-18 13:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bonzini at gcc dot gnu dot org  2005-08-18 13:46 -------
Sorry.

outcnt aliases with outbuf, so the load of t2 cannot be removed.  The GIMPLE
code that is now emitted is something like:


    void
    bi_windup(unsigned char *outbuf, unsigned char bi_buf)
    {
        int t1 = outcnt;
        outbuf[t1] = bi_buf;
        int t2 = outcnt;
        if (t2 == 16384)
                flush_outbuf();
	int t3 = outcnt;
        outbuf[t3] = bi_buf;
    }

where t3 == t2 if flush_outbuf is not called.  My code removes the load into t3
if flush_outbuf is not called.

 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23455


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-08-18 13:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-18  8:22 [Bug tree-optimization/23455] New: load PRE is missing bonzini at gcc dot gnu dot org
2005-08-18 11:47 ` [Bug tree-optimization/23455] " bonzini at gcc dot gnu dot org
2005-08-18 13:15 ` dberlin at dberlin dot org
2005-08-18 13:46 ` bonzini at gcc dot gnu dot org
2005-08-18 13:47 ` dberlin at dberlin dot org
2005-08-18 13:52 ` bonzini 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).