@jqgregory Is there a more detailed explanation somewhere of the "pipeline stall" discussed in this passage from your book? I was asked about it, and I can't think of anything to which it could be referring. (https://imgur.com/76F458o )
[2/2] I can believe some compilers would better handle a[0] a[1] a+=2 than a[i++] a[i++], but a[++i] vs. a[i++] I can't really think of how the compiler would reliably produce more stalls with one than the other.
-
-
Preincrement introduces a data hazard, because you need to wait for ++a to be calculated before it can be used. Whereas the value of a++ can be used immediately, while the increment op makes its way thru the pipeline sans data hazard.
-
Sorry, ++i vs i++ (not ++a/a++). It matters because the very next thing you do is to use i to index into a[]. No useful work can be done in between. So with preinc you have to wait for the result of the inc to pop out the other end of the pipeline before indexing into a[].
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
