public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/32911] Function __attribute__ ((idempotent))
       [not found] <bug-32911-4@http.gcc.gnu.org/bugzilla/>
@ 2012-05-15 15:57 ` walters at verbum dot org
  2012-05-15 15:57   ` Jan Hubicka
  2012-05-15 16:00 ` hubicka at ucw dot cz
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 8+ messages in thread
From: walters at verbum dot org @ 2012-05-15 15:57 UTC (permalink / raw)
  To: gcc-bugs

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

Colin Walters <walters at verbum dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |walters at verbum dot org

--- Comment #2 from Colin Walters <walters at verbum dot org> 2012-05-15 15:51:13 UTC ---
More information about GObject requirements here:

https://bugzilla.gnome.org/show_bug.cgi?id=64994


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

* Re: [Bug middle-end/32911] Function __attribute__ ((idempotent))
  2012-05-15 15:57 ` [Bug middle-end/32911] Function __attribute__ ((idempotent)) walters at verbum dot org
@ 2012-05-15 15:57   ` Jan Hubicka
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Hubicka @ 2012-05-15 15:57 UTC (permalink / raw)
  To: walters at verbum dot org; +Cc: gcc-bugs

Note that I was thinking of similar attribute for C++ iostream initialization code.
Currently every unit including iostream gets a call to the iostream constructor. With LTO
we merge the constructors together and get _alot_ of redundant calls to the construction
code.  Declaring that only first call is needed would save some (quite minor) startup
overehead. (overhead of iostream startup is large, but after inlning all together it
boils down to cca 7000 redundant calls in Mozilla startup that executes quite quickly)


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

* [Bug middle-end/32911] Function __attribute__ ((idempotent))
       [not found] <bug-32911-4@http.gcc.gnu.org/bugzilla/>
  2012-05-15 15:57 ` [Bug middle-end/32911] Function __attribute__ ((idempotent)) walters at verbum dot org
@ 2012-05-15 16:00 ` hubicka at ucw dot cz
  2012-05-15 16:18 ` hubicka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: hubicka at ucw dot cz @ 2012-05-15 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jan Hubicka <hubicka at ucw dot cz> 2012-05-15 15:57:29 UTC ---
Note that I was thinking of similar attribute for C++ iostream initialization
code.
Currently every unit including iostream gets a call to the iostream
constructor. With LTO
we merge the constructors together and get _alot_ of redundant calls to the
construction
code.  Declaring that only first call is needed would save some (quite minor)
startup
overehead. (overhead of iostream startup is large, but after inlning all
together it
boils down to cca 7000 redundant calls in Mozilla startup that executes quite
quickly)


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

* [Bug middle-end/32911] Function __attribute__ ((idempotent))
       [not found] <bug-32911-4@http.gcc.gnu.org/bugzilla/>
  2012-05-15 15:57 ` [Bug middle-end/32911] Function __attribute__ ((idempotent)) walters at verbum dot org
  2012-05-15 16:00 ` hubicka at ucw dot cz
@ 2012-05-15 16:18 ` hubicka at gcc dot gnu.org
  2020-08-06 13:05 ` matthew at wil dot cx
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-05-15 16:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

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

--- Comment #4 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-05-15 15:59:40 UTC ---
Also note that internally we have looping const/looping pure that can be
optimized in this manner, so to large degree this is just matter of exporting
this out to user attributes + declaring sane behaviour on functions returning
void.


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

* [Bug middle-end/32911] Function __attribute__ ((idempotent))
       [not found] <bug-32911-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-05-15 16:18 ` hubicka at gcc dot gnu.org
@ 2020-08-06 13:05 ` matthew at wil dot cx
  2021-09-04 10:27 ` trass3r at gmail dot com
  2024-06-01  4:09 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 8+ messages in thread
From: matthew at wil dot cx @ 2020-08-06 13:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32911

Matthew Wilcox <matthew at wil dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matthew at wil dot cx

--- Comment #6 from Matthew Wilcox <matthew at wil dot cx> ---
I actually have a use for a real idempotent function, that is f(f(x)) == f(x).
I think it's different from the behaviour wanted here which is more of an
initialiser functionality.

The concrete example is Linux's compound_head() macro which takes a pointer to
a struct page and returns a pointer to a (potentially different) struct page. 
A page is its own head, and calls to compound_head can be buried inside macros.

So I'd like gcc to know that given this program:

struct page *compound_head(struct page *) __attribute__((idempotent));

int g(struct page *page)
{
struct page *head = compound_head(page);
return page->refcount;
}

int f(struct page *page)
{
struct page *head = compound_head(page);
return g(head);
}

if it inlines g() into f(), it only needs to make one call to compound_head().

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

* [Bug middle-end/32911] Function __attribute__ ((idempotent))
       [not found] <bug-32911-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-08-06 13:05 ` matthew at wil dot cx
@ 2021-09-04 10:27 ` trass3r at gmail dot com
  2024-06-01  4:09 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 8+ messages in thread
From: trass3r at gmail dot com @ 2021-09-04 10:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32911

Trass3r <trass3r at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trass3r at gmail dot com

--- Comment #7 from Trass3r <trass3r at gmail dot com> ---
OpenGL's bind functions are another example.
They don't return anything so can't be marked pure/const but any subsequent
calls with the same arguments are redundant.

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

* [Bug middle-end/32911] Function __attribute__ ((idempotent))
       [not found] <bug-32911-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-09-04 10:27 ` trass3r at gmail dot com
@ 2024-06-01  4:09 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 8+ messages in thread
From: egallager at gcc dot gnu.org @ 2024-06-01  4:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32911

--- Comment #8 from Eric Gallager <egallager at gcc dot gnu.org> ---
It might also be worth comparing against the attributes [[unsequenced]] and
[[reproducible]] proposed for the C standard:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm

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

* [Bug middle-end/32911] Function __attribute__ ((idempotent))
  2007-07-27  6:33 [Bug c/32911] New: " gnu at behdad dot org
@ 2007-07-27  9:35 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-27  9:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-07-27 09:35 -------
The Java front-end has the same problem.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end


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


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

end of thread, other threads:[~2024-06-01  4:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-32911-4@http.gcc.gnu.org/bugzilla/>
2012-05-15 15:57 ` [Bug middle-end/32911] Function __attribute__ ((idempotent)) walters at verbum dot org
2012-05-15 15:57   ` Jan Hubicka
2012-05-15 16:00 ` hubicka at ucw dot cz
2012-05-15 16:18 ` hubicka at gcc dot gnu.org
2020-08-06 13:05 ` matthew at wil dot cx
2021-09-04 10:27 ` trass3r at gmail dot com
2024-06-01  4:09 ` egallager at gcc dot gnu.org
2007-07-27  6:33 [Bug c/32911] New: " gnu at behdad dot org
2007-07-27  9:35 ` [Bug middle-end/32911] " pinskia 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).