[llvm] [RISCV] Add load/store clustering in post machine schedule (PR #111504)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 20:40:58 PDT 2024


wangpc-pp wrote:

> Why is this what we want?
> 
> ```
> ld a1, 0(a0)
> ld a2, 8(a0)
> addi a3, a1, 1
> addi a4, a2, 1
> ```
> 
> What is problem if there is an add between them? Is there some fusion going on in the hardware? I understand why you want them loads ordered near each other if they access the same cache line, but I don't understand why arithmetic between them is bad?

Oh, sorry, my example may not be exact. Several reasons:
1. If the result of enabling pre-ra scheduling is what we are expecting, then I think we should get the same result after post-ra scheduling, right?
2. Some μ-arch things require this:
  * As what you have pointed out, fusion is one thing.
  * Another thing is about store clustering. Store buffer may be impacted as we interleave arithmetic/load(which is not shown in my example) between stores.

Anyway, we saw the benefit and if it is not common for all μ-arch, we can make it a feature.

https://github.com/llvm/llvm-project/pull/111504


More information about the llvm-commits mailing list