Hi all, Is there a macro in boost for something like MSVC __forceinline. Currently I have in the project: #if defined __GNUC__ #define FORCE_INLINE __attribute__((always_inline)) #define NO_INLINE __attribute__((noinline)) #elif defined _MSC_VER #define FORCE_INLINE __forceinline #define NO_INLINE __declspec(noinline) #else //#error "no inlines" #define FORCE_INLINE inline #define NO_INLINE #endif I am wondering whether I can get rid of it and use boost for it? Artem
Why don't you trust your compiler to decide when inlining a function is a good choice for an optimization? :) -----Original Message----- From: Artem Alimarine [mailto:artem@emulatorsinternational.com] Sent: Friday, July 14, 2006 6:59 AM To: boost-users@lists.boost.org Subject: [Boost-users] force inline Hi all, Is there a macro in boost for something like MSVC __forceinline. Currently I have in the project: #if defined __GNUC__ #define FORCE_INLINE __attribute__((always_inline)) #define NO_INLINE __attribute__((noinline)) #elif defined _MSC_VER #define FORCE_INLINE __forceinline #define NO_INLINE __declspec(noinline) #else //#error "no inlines" #define FORCE_INLINE inline #define NO_INLINE #endif I am wondering whether I can get rid of it and use boost for it? Artem _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Sometimes compilers make bad decisions that result in 2x worse
performance. This is especially true when writing math libraries. It's
useful to have a __forceinline option.
On 7/14/06, Michael Nicolella
Why don't you trust your compiler to decide when inlining a function is a good choice for an optimization? :)
Michael Nicolella wrote:
Why don't you trust your compiler to decide when inlining a function is a good choice for an optimization? :)
I have analyzed the assembler output of the most performance critical part of the project and figured out that inlining some functions will lead to better code. Note that the creators of GCC and MSVC have made the forceinline options because they know that the compiler is not always able to make a good decision about inlining. This options are provided to enable the user to guide the compiler optimizations. It is not that you gain much from the inlining of functions by getting rid of extra function calls. It is that inlining enables other optimization possibilities. For instance, constant folding cannot be performed before the function returning a constant is inlined.
participants (3)
-
Artem Alimarine
-
Michael Nicolella
-
Stan Vasilyev