SPRUI04F july 2015 – april 2023
Following are memory alias examples that use the .mdep and .no_mdep directives.
The .mdep r1, r2 directive declares that LDW must be before STW. In this case, src and dst might point to the same array.
fn: .cproc dst, src, cnt
.reg tmp
.no_mdep
.mdep r1, r2
LDW *src{r1}, tmp
STW cnt, *dst{r2}
.return tmp
.endproc
Here, .mdep r2, r1 indicates that STW must occur before LDW. Since STW is after LDW in the code, the dependence relation is across loop iterations. The STW instruction writes a value that may be read by the LDW instruction on the next iteration. In this case, a 6-cycle recurrence is created.
fn: .cproc dst, src, cnt
.reg tmp
.no_mdep
.mdep r2, r1
LOOP: .trip 100
LDW *src++{r1}, tmp
STW tmp, *dst++{r2}
[cnt] SUB cnt, 1, cnt
[cnt] B LOOP
.endproc
Do not confuse memory alias disambiguation with the handling of memory bank conflicts. These may seem similar because they each deal with memory references and the effect of those memory references on the instruction schedule. Alias disambiguation is a correctness issue, bank conflicts are a performance issue. A memory dependence has a much broader impact on the instruction schedule than a bank conflict. It is best to keep these two topics separate.
For volatile references, use .volatile rather than .mdep.