public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* c++: Shrink lambda-expr
@ 2020-07-22 15:11 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-07-22 15:11 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]

I noticed the default capture mode and the discriminator both used ints. 
  That seems excessive.  This shrinks them to 8 bits and 16 bits 
respectively.  I suppose the discriminator could use the remaining 24 
bits of an int allocation unit, if we're worried about more that 64K 
lambdas per function.  I know, users are strange :)  On a 64 bit system 
this saves 64 bits, because we also had 32 bits of padding added.

             gcc/cp/
             * cp-tree.h (struct tree_lambda_expr): Shrink
             default_capture_mode & discriminator.


-- 
Nathan Sidwell

[-- Attachment #2: lambda-expr.diff --]
[-- Type: text/x-patch, Size: 532 bytes --]

diff --git i/gcc/cp/cp-tree.h w/gcc/cp/cp-tree.h
index a599f3bad1c..d43c53ae29a 100644
--- i/gcc/cp/cp-tree.h
+++ w/gcc/cp/cp-tree.h
@@ -1442,8 +1442,8 @@ struct GTY (()) tree_lambda_expr
   tree extra_scope;
   vec<tree, va_gc> *pending_proxies;
   location_t locus;
-  enum cp_lambda_default_capture_mode_type default_capture_mode;
-  int discriminator;
+  enum cp_lambda_default_capture_mode_type default_capture_mode : 8;
+  short int discriminator;
 };
 
 /* Non-zero if this template specialization has access violations that

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-22 15:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 15:11 c++: Shrink lambda-expr Nathan Sidwell

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