Category : compiler-optimization

C++17 std::clamp is a template function that makes sure the input value is not less than the given minimum and less than the given maximum, and returns the input value; otherwise it returns the minimum or the maximum respectively. The goal is to optimize it, assuming the following: The type parameter is 32 bit or ..

Read more

If a function is static inline, inline here works only as a suggestion. With either static or static inline the function has internal linkage, and the compiler knows this function cannot be called outside of the translation unit. Thus possibly no symbol is emitted for this function with compiler optimization. In case of inline functions ..

Read more

In Lisp you can optimize code by evaluating conditionals during compile time in a Macro. As in, you have a macro (compute-for-N 1) evaluate to code-1 and (compute-for-N 2) evaluate to code-2. If you write something similar in C++, a very naïve compiler would evaluate the conditional during execution, slowing the program down. My question ..

Read more