# Must the following instruction wait for completion of a memory load ？

**URL:** <https://forums.sifive.com/t/must-the-following-instruction-wait-for-completion-of-a-memory-load/1927>\
**Category:** SiFive RISC-V Core IP Evaluation\
**Created:** [December 29, 2018, 3:53am UTC](https://forums.sifive.com/t/must-the-following-instruction-wait-for-completion-of-a-memory-load/1927 "2018-12-29T03:53:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daiw](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@daiw](https://forums.sifive.com/u/daiw)\
**Post date:** [December 29, 2018, 3:53am UTC](https://forums.sifive.com/t/must-the-following-instruction-wait-for-completion-of-a-memory-load/1927/1 "2018-12-29T03:53:45Z")

</div>

If a memory load need N cycles to be completed, must N instructions immediately followed the  
load instruction wait even these N instructions do not need the result of load ？

thans a lot !

---

<div class="post-metadata">

**Author:** ![bruce](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/bruce/32/452_2.png) [@bruce](https://forums.sifive.com/u/bruce)\
**Post date:** [December 29, 2018, 3:55am UTC](https://forums.sifive.com/t/must-the-following-instruction-wait-for-completion-of-a-memory-load/1927/2 "2018-12-29T03:55:30Z")

</div>

No, only the instruction that uses the result of the load (and any instructions following it) will stall waiting for the load.

---

<div class="post-metadata">

**Author:** ![daiw](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@daiw](https://forums.sifive.com/u/daiw)\
**Post date:** [December 29, 2018, 7:48am UTC](https://forums.sifive.com/t/must-the-following-instruction-wait-for-completion-of-a-memory-load/1927/3 "2018-12-29T07:48:21Z")

</div>

Thanks for your quick feedback.  
What’s more, is there any cycle penalty for a instruction which is immediately following a store instruction and change the source register of the store instruction ?  
thanks a lot !

---

<div class="post-metadata">

**Author:** ![bruce](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/bruce/32/452_2.png) [@bruce](https://forums.sifive.com/u/bruce)\
**Post date:** [December 29, 2018, 7:57am UTC](https://forums.sifive.com/t/must-the-following-instruction-wait-for-completion-of-a-memory-load/1927/4 "2018-12-29T07:57:45Z")

</div>

No. The only interlocks are trying to read or write a register that a previous long-latency instruction (load, multiply, divide) is still waiting to write.

Also if you write to a memory address than then try to read from the same address while the store is still in the write buffer (the depth isn’t documented) then there’s a 5 cycle penalty.
