public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Improve VEC_BASE
@ 2011-11-07 21:34 Jakub Jelinek
  2011-11-07 23:25 ` Richard Guenther
  2011-11-11  8:27 ` Jeff Law
  0 siblings, 2 replies; 11+ messages in thread
From: Jakub Jelinek @ 2011-11-07 21:34 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

Hi!

This patch attempts to optimize VEC_BASE if we know
that offsetof of base is 0 (unless the compiler is doing something
strange, it is true).
It doesn't have a clear code size effect, some .text sections
grew, supposedly because of more inlining, some .text sections shrunk.

Bootstrapped/regtested on x86_64-linux and i686-linux.

2011-11-07  Jakub Jelinek  <jakub@redhat.com>

	* vec.h (VEC_BASE): If base is at offset 0 in the structure,
	use &(P)->base even if P is NULL.

--- gcc/vec.h.jj	2011-09-08 11:21:10.000000000 +0200
+++ gcc/vec.h	2011-11-07 18:45:33.000000000 +0100
@@ -549,7 +549,12 @@ typedef struct VEC(T,A)							  \
 } VEC(T,A)
 
 /* Convert to base type.  */
+#if GCC_VERSION >= 4000
+#define VEC_BASE(P) \
+  ((offsetof (__typeof (*P), base) == 0 || (P)) ? &(P)->base : 0)
+#else
 #define VEC_BASE(P)  ((P) ? &(P)->base : 0)
+#endif
 
 /* Vector of integer-like object.  */
 #define DEF_VEC_I(T)							  \

	Jakub

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

end of thread, other threads:[~2011-11-11 18:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-07 21:34 [PATCH] Improve VEC_BASE Jakub Jelinek
2011-11-07 23:25 ` Richard Guenther
2011-11-08  0:34   ` Jeff Law
2011-11-08 10:12     ` Richard Guenther
2011-11-08 10:29       ` Richard Guenther
2011-11-08 19:35       ` Jeff Law
2011-11-08 19:54   ` Jeff Law
2011-11-09  9:42     ` Richard Guenther
2011-11-11  8:27 ` Jeff Law
2011-11-11  9:42   ` Jakub Jelinek
2011-11-11 20:21     ` Jeff Law

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).