4

The OpenGL mathematics library defines a macro GLM_CONSTEXPR_SIMD which causes expressions like vec3(1.0f, 0.0f, 0.0f, 1.0f) to be a constexpr only when generating platform-independent code, i.e., only whenGLM_ARCH is GLM_ARCH_PURE.

I assume this is done for performance reasons, but why would making something non-constexpr increase performance? And how does SIMD play a role in the decision?

Tony Beta Lambda
  • 529
  • 3
  • 18

1 Answers1

1

This is most probably related to the fact that SIMD intrinsics are not defined constexpr. When you generate platform-independent code, it does not use intrinsics and thus, it can be declared constexpr. However, as soon as you pinpoint a platform e.g. with SSE/AVX, in order to benefit from these SIMD functions, constexpr must be stripped away.

Additional info available at Constexpr and SSE intrinsics

Naebaf
  • 321
  • 1
  • 8