public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/57999] New: Missed constant propagation into trampolines
@ 2013-07-27  8:08 alexey.tourbin at gmail dot com
  2013-11-09 22:43 ` [Bug tree-optimization/57999] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: alexey.tourbin at gmail dot com @ 2013-07-27  8:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57999
           Summary: Missed constant propagation into trampolines
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexey.tourbin at gmail dot com

Created attachment 30562
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30562&action=edit
mergesort.c

The attached source file is a simplistic mergesort implementation (which
actually works, except for the deliberate assertion failure).  Its basic
structure is as follows.

static inline void msort(void *b, size_t n, const size_t s,
        int (*cmp)(), void *t)
{
    auto void msort_rec(char *b, size_t n);
    void msort_rec(char *b, size_t n)
    {  
        /* Copying will be inlined */
        assert(__builtin_constant_p(s));
        ...
        /* Recursively sort a1 and a2 */
        msort_rec(b1, n1);
        msort_rec(b2, n2);
        ...
        /* Merge */
        ...
            if (cmp(b1, b2) <= 0) {
                n1--;
                memcpy(tmp, b1, s);
                b1 += s;
        ...
    }
    msort_rec(b, n);
}

When the size of the element (size_t s) is a compile-time constant, the
resulting code would benefit greatly from inlining per-element memcpy() calls.
However, gcc fails to propagate the constant size into the trampoline - the
assertion actually fails, and otherwise the resulting code is roughly 2 times
slower.


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

* [Bug tree-optimization/57999] Missed constant propagation into trampolines
  2013-07-27  8:08 [Bug tree-optimization/57999] New: Missed constant propagation into trampolines alexey.tourbin at gmail dot com
@ 2013-11-09 22:43 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-11-09 22:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-09
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, we don't have any IPA based on optimizations on nested functions.


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

end of thread, other threads:[~2013-11-09 22:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-27  8:08 [Bug tree-optimization/57999] New: Missed constant propagation into trampolines alexey.tourbin at gmail dot com
2013-11-09 22:43 ` [Bug tree-optimization/57999] " 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).