diff --git a/source/blender/functions/FN_multi_function_builder.hh b/source/blender/functions/FN_multi_function_builder.hh index 997f52f4066..20b28658932 100644 --- a/source/blender/functions/FN_multi_function_builder.hh +++ b/source/blender/functions/FN_multi_function_builder.hh @@ -124,13 +124,19 @@ namespace detail { * instead of a `VArray`). */ template -void execute_array(TypeSequence /*param_tags*/, - std::index_sequence /*indices*/, - ElementFn element_fn, - MaskT mask, - /* Use restrict to tell the compiler that pointer inputs do not alias each - * other. This is important for some compiler optimizations. */ - Args &&__restrict... args) +/* Perform additional optimizations on this loop because it is a very hot loop. For example, the + * math node in geometry nodes is processed here. */ +#if (defined(__GNUC__) && !defined(__clang__)) +[[gnu::optimize("-funroll-loops")]] [[gnu::optimize("O3")]] +#endif +void execute_array( + TypeSequence /*param_tags*/, + std::index_sequence /*indices*/, + ElementFn element_fn, + MaskT mask, + /* Use restrict to tell the compiler that pointer inputs do not alias each + * other. This is important for some compiler optimizations. */ + Args &&__restrict... args) { for (const int64_t i : mask) { element_fn([&]() -> decltype(auto) {