[PATCH] D156404: [RISCV] Use x0 in vsetvli when avl is equal to vlmax.
Jianjian Guan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 01:22:03 PDT 2023
jacquesguan updated this revision to Diff 545050.
jacquesguan added a comment.
address comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156404/new/
https://reviews.llvm.org/D156404
Files:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll
Index: llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll
===================================================================
--- llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll
+++ llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll
@@ -1,8 +1,14 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v \
-; RUN: -verify-machineinstrs | FileCheck %s
+; RUN: -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,VLENUNKNOWN
; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v \
-; RUN: -verify-machineinstrs | FileCheck %s
+; RUN: -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK,VLENUNKNOWN
+; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v \
+; RUN: -riscv-v-vector-bits-max=128 -verify-machineinstrs \
+; RUN: | FileCheck %s --check-prefixes=CHECK,VLEN128
+; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v \
+; RUN: -riscv-v-vector-bits-max=128 -verify-machineinstrs \
+; RUN: | FileCheck %s --check-prefixes=CHECK,VLEN128
declare iXLen @llvm.riscv.vsetvli.iXLen(iXLen, iXLen, iXLen)
declare iXLen @llvm.riscv.vsetvlimax.iXLen(iXLen, iXLen)
@@ -135,3 +141,18 @@
%vl = call iXLen @llvm.riscv.vsetvli.iXLen(iXLen -1, iXLen 0, iXLen 0)
ret iXLen %vl
}
+
+define iXLen @test_vsetvli_eqvlmax_e8m8(iXLen %avl) nounwind {
+; VLENUNKNOWN-LABEL: test_vsetvli_eqvlmax_e8m8:
+; VLENUNKNOWN: # %bb.0:
+; VLENUNKNOWN-NEXT: li a0, 128
+; VLENUNKNOWN-NEXT: vsetvli a0, a0, e8, m8, ta, ma
+; VLENUNKNOWN-NEXT: ret
+;
+; VLEN128-LABEL: test_vsetvli_eqvlmax_e8m8:
+; VLEN128: # %bb.0:
+; VLEN128-NEXT: vsetvli a0, zero, e8, m8, ta, ma
+; VLEN128-NEXT: ret
+ %vl = call iXLen @llvm.riscv.vsetvli.iXLen(iXLen 128, iXLen 0, iXLen 3)
+ ret iXLen %vl
+}
Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -552,6 +552,12 @@
SDValue VLOperand;
unsigned Opcode = RISCV::PseudoVSETVLI;
+ if (auto *C = dyn_cast<ConstantSDNode>(Node->getOperand(1))) {
+ const unsigned VLEN = Subtarget->getRealMinVLen();
+ if (VLEN == Subtarget->getRealMaxVLen())
+ if (VLEN / RISCVVType::getSEWLMULRatio(SEW, VLMul) == C->getZExtValue())
+ VLMax = true;
+ }
if (VLMax || isAllOnesConstant(Node->getOperand(1))) {
VLOperand = CurDAG->getRegister(RISCV::X0, XLenVT);
Opcode = RISCV::PseudoVSETVLIX0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156404.545050.patch
Type: text/x-patch
Size: 2569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/60997785/attachment.bin>
More information about the llvm-commits
mailing list