This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Something like __builtin_expect for enums?


Hello,

in GCC we can use __builtin_expect() to give the compiler a branch prediction information for expressions. Is it possible to use an attribute for enums to say that enum value A is more likely than B, e.g.

enum e {
	__attribute__((likely)) A,
	B,
	C
};

This is useful for status codes that are encoded in an enum, e.g.

enum status = func();
if (status != ERROR_STATUS) {
  blablub();
}

I found nothing in the manual. Maybe this is a useful enhancement for the GCC?

--
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]