3 ms·
In some cases there are other reasons for hoiting the dereference too. For example, Crystal will check if the array access is out of bounds and by hoisting vari
by yxhuvud 3y ago
In some cases there are other reasons for hoiting the dereference too. For example, Crystal will check if the array access is out of bounds and by hoisting variables that will be done a lot less seldom, which can have huge effects for code that does a lot of that, like matmul.
- cm2187 3y agoDoesn’t that get mostly optimised away by the cpu branch prediction?
- beagle3 3y agoThe branch does, but you still have the comparison itself, and also the branch instruction to decide and skip (although thanks to branch prediction, your pipeline doesn’t get flushed). If you have enough idle execution units, you might not see a difference in wall clock time. But with many algorithms you can put those units to good use.
- yxhuvud 3y agoThe branch does, but not optimizations that could be done, like vectorization.