4 ms·
> For real programs, you should demand that the compiler hoist such checks out of the loop, which may then be vectorized the usual way. LLVM sometimes does thi
by nextaccountic 4y ago
> For real programs, you should demand that the compiler hoist such checks out of the loop, which may then be vectorized the usual way.
LLVM sometimes does this, but when it doesn't, you may insert asserts to guide the optimizer, as explained here https://news.ycombinator.com/item?id=33808853 https://news.ycombinator.com/item?id=33808853
I think this technique works in C and C++ too (if you use clang or gcc)
- moloch-hai 4y agoSometimes a __builtin_assert(c) may help (which is not the same as the normal assertion, which won't). Other times, you need to make a private copy of a value that the compiler could not otherwise assume will not be clobbered.