logoalt Hacker News

summarybottoday at 12:40 PM1 replyview on HN

That's pretty cool. Is there something obcluding the compiler from noticing this parallelization opportunity without the new `if` ?

My understanding is the assignment and the evaluation are somehow coupled in this case based on the essay, but I could use an explanation.


Replies

purplesyringatoday at 12:55 PM

The optimization in the post is only advantageous if `next_j[i][j] == j` holds often enough. Without prior knowledge, the compiler can't know if it's going to improve performance, and the worst losses are greater than the best wins (branch misprediction is very expensive), so it decides not to interfere.