Re:Beating the L1 cache with value speculation
by solidangle on Friday July 23, 2021 @11:04AM
(#27931472)
```
if (node != next) {
node = node->next;
}
```
How does this work? Shouldn't this be
```
if (node != next) { node = next; }
```?
[ Parent
| on HN ]
Re:Beating the L1 cache with value speculation
by tinus_hn on Friday July 23, 2021 @02:41PM
(#27934196)
That looks weird, why would you need to test if two values are equal if you’re going to assign them to be equal anyway?
That is the trick.
In the happy path you are not assigning(`node=next`).
It is taken care of by `node++`, which removes the loop dependency and the processor can use the full instruction level parallelism.
Re:Beating the L1 cache with value speculation
by ectopod on Friday July 23, 2021 @03:14PM
(#27934490)
It looks like a bug. The unhappy path contains both `node++` and `node=node->next`. Note that this is in the code following "Let’s go back to the code we showed for value speculation in C:", which is actually different from the preceding code it's supposed to be a copy of. I guess it's a typo.
Re:Beating the L1 cache with value speculation
by ectopod on Friday July 23, 2021 @06:49PM
(#27936517)
The author has fixed this discrepancy now.