From a6908d7db001b86468ddd3da67453d6be1c84138 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Mon, 11 Jul 2022 22:34:07 -0400 Subject: [PATCH] Note that the compiler performs loop unrolling (#46001) This makes the `@generated` example obsolete, though it is still illustrative. --- doc/src/manual/metaprogramming.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/src/manual/metaprogramming.md b/doc/src/manual/metaprogramming.md index d718bf17e4878..8fddb8868c7d4 100644 --- a/doc/src/manual/metaprogramming.md +++ b/doc/src/manual/metaprogramming.md @@ -1353,7 +1353,8 @@ Both these implementations, although different, do essentially the same thing: a over the dimensions of the array, collecting the offset in each dimension into the final index. However, all the information we need for the loop is embedded in the type information of the arguments. -Thus, we can utilize generated functions to move the iteration to compile-time; in compiler parlance, +This allows the compiler to move the iteration to compile time and eliminate the runtime loops +altogether. We can utilize generated functions to achieve a simmilar effect; in compiler parlance, we use generated functions to manually unroll the loop. The body becomes almost identical, but instead of calculating the linear index, we build up an *expression* that calculates the index: