This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Commit f590963
authored
[RISCV] Implement RISCVTTIImpl::getPreferredAddressingMode for HasVendorXCVmem (llvm#120533)
For a simple matmult kernel this heuristic reduces the length of the
critical basic block from 15 to 20 instructions, resulting in a 20%
speedup.
**Without heuristic:**
```
13688: 001b838b cv.lb t2, (s7), 0x1
1368c: 09cdbcab cv.lb s9, t3(s11)
13690: 089db62b cv.lb a2, s1(s11)
13694: 092dbdab cv.lb s11, s2(s11)
13698: 001d028b cv.lb t0, (s10), 0x1
1369c: 00f282b3 add t0, t0, a5
136a0: 9072b52b cv.mac a0, t0, t2
136a4: 9192bfab cv.mac t6, t0, s9
136a8: 90c2beab cv.mac t4, t0, a2
136ac: 91b2bf2b cv.mac t5, t0, s11
136b0: fffc0c13 addi s8, s8, -0x1
136b4: 018e0633 add a2, t3, s8
136b8: 91b2b0ab cv.mac ra, t0, s11
136bc: 000b8d93 mv s11, s7
136c0: fc0614e3 bnez a2, 0x13688 <muriscv_nn_vec_mat_mult_t_s8+0x2f0>
#instrs = 15
```
**With heuristic:**
```
7bc0: 001c860b cv.lb a2, (s9), 0x1
7bc4: 001e0d0b cv.lb s10, (t3), 0x1
7bc8: 001e808b cv.lb ra, (t4), 0x1
7bcc: 0015038b cv.lb t2, (a0), 0x1
7bd0: 001c028b cv.lb t0, (s8), 0x1
7bd4: 00f282b3 add t0, t0, a5
7bd8: 90c2bfab cv.mac t6, t0, a2
7bdc: 91a2b92b cv.mac s2, t0, s10
7be0: 9012b5ab cv.mac a1, t0, ra
7be4: 9072b9ab cv.mac s3, t0, t2
7be8: 9072b72b cv.mac a4, t0, t2
7bec: fc851ae3 bne a0, s0, 0x7bc0 <muriscv_nn_vec_mat_mult_t_s8+0x338>
#instrs = 12
improvement = 1 - 12/15 = 0.2 = 20%
```1 parent e50ec3e commit f590963
File tree
3 files changed
+46
-0
lines changed- llvm
- lib/Target/RISCV
- test/CodeGen/RISCV
3 files changed
+46
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2329 | 2329 | | |
2330 | 2330 | | |
2331 | 2331 | | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
2332 | 2341 | | |
2333 | 2342 | | |
2334 | 2343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
391 | 394 | | |
392 | 395 | | |
393 | 396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments