Allow unrolling loops over arrays of known size #6203
SaculRennorb
started this conversation in
Proposals
Replies: 1 comment
-
|
So the problem here at the moment is that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes it is very useful to be able to unroll a loop over a array, specifically to express bit manipulation over some wider buffer of things.
Currently there are two separate restrictions that make this not possible:
The first issue is that the
#unrollpragma only works on range based for loops, e.g. loops with a range expression. While the error does not reflect this, the docs say as much.I suspect this is the reason why the compiler does not like me taking the address of
ahere either, but this is probably a minor aspect of the whole thing.The main issue is that
already fails to compile, with the error of
An '#unroll for' expression must be known at compile time. This error is misleading, as the expression is known at compile time, and it should be fairly trivial to translate this intoas the length of the array is known. Additionally it should also be trivial to translate the addressable and value + index versions of the loop in a similar fashion.
In the real world I ran into this while writing some hash functions.
Beta Was this translation helpful? Give feedback.
All reactions