public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX)
@ 2011-11-23  0:27 pinskia at gcc dot gnu.org
  2011-11-23  1:18 ` [Bug tree-optimization/51275] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-23  0:27 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51275
           Summary: CLOBBERS can be optimized if they are right before the
                    return (or RESX)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pinskia@gcc.gnu.org


Created attachment 25890
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25890
Patch which optimizes the clobbers

As mentioned in Bug #51264 comment #10, clobbers can be optimized but only
after inlining.  I attached a patch which does the optimization in
fold_all_builtins.  With this patch, most of the reason for adding
-fno-exceptions to compiling GCC is gone (though inlining is still different).


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

* [Bug tree-optimization/51275] CLOBBERS can be optimized if they are right before the return (or RESX)
  2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
@ 2011-11-23  1:18 ` pinskia at gcc dot gnu.org
  2011-11-23  2:25 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-23  1:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-11-23 00:40:40 UTC ---
I think this patch has a bug in it when dealing with DEBUG_STMT's.


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

* [Bug tree-optimization/51275] CLOBBERS can be optimized if they are right before the return (or RESX)
  2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
  2011-11-23  1:18 ` [Bug tree-optimization/51275] " pinskia at gcc dot gnu.org
@ 2011-11-23  2:25 ` pinskia at gcc dot gnu.org
  2011-11-23 11:40 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-23  2:25 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #25890|0                           |1
        is obsolete|                            |
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-11-23
         AssignedTo|unassigned at gcc dot       |pinskia at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-11-23 01:50:53 UTC ---
Created attachment 25892
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25892
New patch

Here is a new patch which fixes the DEBUG_STMT issue which I thought of after I
created the bug.


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

* [Bug tree-optimization/51275] CLOBBERS can be optimized if they are right before the return (or RESX)
  2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
  2011-11-23  1:18 ` [Bug tree-optimization/51275] " pinskia at gcc dot gnu.org
  2011-11-23  2:25 ` pinskia at gcc dot gnu.org
@ 2011-11-23 11:40 ` jakub at gcc dot gnu.org
  2011-11-23 14:36 ` matz at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-11-23 11:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-11-23 10:54:07 UTC ---
The question is if we should do this in the fab pass or elsewhere.  Also, I'm
afraid it is O(n^2) compile time written this way, consider a basic block
containing 100000 clobber stmts followed by a normal assignment,
optimize_clobbers will return 100000 times false in that case, the first call
will walk through 100001 stmts, second call through 100000 stmts, third through
99999 stmts, etc. to find that out.
So, IMHO it would be better to call optimize_clobbers not for each clobber
stmt, but instead for the GIMPLE_RETURN or GIMPLE_RESX and walk backwards from
it.

BTW, for the internal GIMPLE_RESX I think we perhaps could move over the
clobber stmts to where the exception would land.


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

* [Bug tree-optimization/51275] CLOBBERS can be optimized if they are right before the return (or RESX)
  2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-11-23 11:40 ` jakub at gcc dot gnu.org
@ 2011-11-23 14:36 ` matz at gcc dot gnu.org
  2011-11-29 23:05 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: matz at gcc dot gnu.org @ 2011-11-23 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Michael Matz <matz at gcc dot gnu.org> 2011-11-23 14:12:11 UTC ---
Andrew: yes, I considered something similar.  To work really well it requires
some changes to the conflict generation code, though.  Without the clobbers
all objects stay live on the exit-block entry and therefore conflict (and
hence won't be shared).  Conflicts generated only because of the exit block
need to be ignored.

As Jakub says, the implementation should be improved by walking from the exit
block upwards. fab seems like the wrong place to do this.  Something like
DSE feels more natural perhaps.  But it's correct that the removal should
happen after inlining but before eh optimizations.


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

* [Bug tree-optimization/51275] CLOBBERS can be optimized if they are right before the return (or RESX)
  2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-11-23 14:36 ` matz at gcc dot gnu.org
@ 2011-11-29 23:05 ` pinskia at gcc dot gnu.org
  2011-12-05 15:50 ` rguenth at gcc dot gnu.org
  2011-12-05 16:03 ` matz at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-29 23:05 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |NEW
         AssignedTo|pinskia at gcc dot gnu.org  |unassigned at gcc dot
                   |                            |gnu.org

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-11-29 22:54:16 UTC ---
Actually I was just posting a first pass at fixing this and not really doing a
full patch just yet.


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

* [Bug tree-optimization/51275] CLOBBERS can be optimized if they are right before the return (or RESX)
  2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-11-29 23:05 ` pinskia at gcc dot gnu.org
@ 2011-12-05 15:50 ` rguenth at gcc dot gnu.org
  2011-12-05 16:03 ` matz at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-05 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-05 15:49:44 UTC ---
Another approach is to not create CLOBBERs in the outermost scope at all
but re-create those during inlining when building the containing BLOCK.
That would probably avoid CLOBBERs for most C code that is not inlined.


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

* [Bug tree-optimization/51275] CLOBBERS can be optimized if they are right before the return (or RESX)
  2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-12-05 15:50 ` rguenth at gcc dot gnu.org
@ 2011-12-05 16:03 ` matz at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: matz at gcc dot gnu.org @ 2011-12-05 16:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Michael Matz <matz at gcc dot gnu.org> 2011-12-05 16:02:10 UTC ---
As said, this would still require ugly fiddling with exception edges.
Getting rid of some of the clobbers a posteriori seems cleaner.


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

end of thread, other threads:[~2011-12-05 16:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-23  0:27 [Bug tree-optimization/51275] New: CLOBBERS can be optimized if they are right before the return (or RESX) pinskia at gcc dot gnu.org
2011-11-23  1:18 ` [Bug tree-optimization/51275] " pinskia at gcc dot gnu.org
2011-11-23  2:25 ` pinskia at gcc dot gnu.org
2011-11-23 11:40 ` jakub at gcc dot gnu.org
2011-11-23 14:36 ` matz at gcc dot gnu.org
2011-11-29 23:05 ` pinskia at gcc dot gnu.org
2011-12-05 15:50 ` rguenth at gcc dot gnu.org
2011-12-05 16:03 ` matz 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).