Skip to content

Commit d1789c1

Browse files
[RISCV][VLOPT] Add getOperandInfo for Vector Store Whole Register Instructions
We don't add tests for incompatible LMUL since it would break the type system.
1 parent 9bb29c3 commit d1789c1

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,25 @@ static OperandInfo getOperandInfo(const MachineInstr &MI,
247247
llvm_unreachable("Configuration setting instructions do not read or write "
248248
"vector registers");
249249

250+
// Vector Store Whole Register Instructions
251+
// EMUL=nr. EEW=eew. Since in-register byte layouts are idential to in-memory
252+
// byte layouts, the same data is writen to destination register regardless
253+
// of EEW. eew is just a hint to the hardware and has not functional impact.
254+
// Therefore, it is be okay if we ignore eew and always use the same EEW to
255+
// create more optimization opportunities.
256+
// FIXME: Instead of using any SEW, we really should return the SEW in the
257+
// instruction and add a field to OperandInfo that says the SEW is just a hint
258+
// so that this optimization can use any sew to construct a ratio.
259+
case RISCV::VS1R_V:
260+
return OperandInfo(RISCVII::VLMUL::LMUL_1, 0);
261+
case RISCV::VS2R_V:
262+
return OperandInfo(RISCVII::VLMUL::LMUL_2, 0);
263+
case RISCV::VS4R_V:
264+
return OperandInfo(RISCVII::VLMUL::LMUL_4, 0);
265+
case RISCV::VS8R_V:
266+
return OperandInfo(RISCVII::VLMUL::LMUL_8, 0);
267+
268+
250269
// Vector Integer Arithmetic Instructions
251270
// Vector Single-Width Integer Add and Subtract
252271
case RISCV::VADD_VI:

llvm/test/CodeGen/RISCV/rvv/vl-opt-op-info.mir

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,28 @@ body: |
483483
%x:vr = PseudoVADD_VV_MF4 $noreg, $noreg, $noreg, -1, 3 /* e8 */, 0
484484
%y:vr = PseudoVNSRL_WV_MF2 $noreg, $noreg, %x, 1, 3 /* e8 */, 0
485485
...
486+
---
487+
name: vsNr_v
488+
body: |
489+
bb.0:
490+
; CHECK-LABEL: name: vsNr_v
491+
; CHECK: %x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, -1, 3 /* e8 */, 0 /* tu, mu */
492+
; CHECK-NEXT: %y:gpr = ADDI $x0, 1
493+
; CHECK-NEXT: VS1R_V %x, %y
494+
%x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, -1, 3 /* e8 */, 0
495+
%y:gpr = ADDI $x0, 1
496+
VS1R_V %x, %y,
497+
...
498+
# FIXME: We can optimize this
499+
---
500+
name: vsNr_v_eew
501+
body: |
502+
bb.0:
503+
; CHECK-LABEL: name: vsNr_v_eew
504+
; CHECK: %x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, -1, 3 /* e8 */, 0 /* tu, mu */
505+
; CHECK-NEXT: %y:gpr = ADDI $x0, 1
506+
; CHECK-NEXT: VS1R_V %x, %y
507+
%x:vr = PseudoVADD_VV_M1 $noreg, $noreg, $noreg, -1, 3 /* e8 */, 0
508+
%y:gpr = ADDI $x0, 1
509+
VS1R_V %x, %y
510+
...

0 commit comments

Comments
 (0)