[llvm] 9aaa74a - [RISCV] Add patterns of SET[U]LT_VI for STECC forms
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 24 00:51:09 PST 2022
Author: Chenbing.Zheng
Date: 2022-01-24T08:50:49Z
New Revision: 9aaa74aeeff37b85e29369287ee94773e699b8b7
URL: https://github.com/llvm/llvm-project/commit/9aaa74aeeff37b85e29369287ee94773e699b8b7
DIFF: https://github.com/llvm/llvm-project/commit/9aaa74aeeff37b85e29369287ee94773e699b8b7.diff
LOG: [RISCV] Add patterns of SET[U]LT_VI for STECC forms
This patch optmizes "li a0, 5
vmsgt[u].vx v10, v8, a0"
-> "vmsgt[u].vi v10, v8, 5"
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D118014
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-setcc.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
index 0ac959d79a024..7b556174bbf0c 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
@@ -820,6 +820,8 @@ foreach vti = AllIntegerVectors in {
defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSNE", SETNE, SETNE>;
defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLE", SETLE, SETGE>;
defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSLEU", SETULE, SETUGE>;
+ defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGT", SETGT, SETLT>;
+ defm : VPatIntegerSetCCVL_VI_Swappable<vti, "PseudoVMSGTU", SETUGT, SETULT>;
defm : VPatIntegerSetCCVL_VIPlus1<vti, "PseudoVMSLE", SETLT,
SplatPat_simm5_plus1>;
diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-setcc.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-setcc.ll
index 9d0fb925a46e2..403fc6d7f43ed 100644
--- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-setcc.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-setcc.ll
@@ -553,7 +553,7 @@ define void @setgt_vi_v64i8(<64 x i8>* %x, <64 x i1>* %z) {
; CHECK-NEXT: li a2, 64
; CHECK-NEXT: vsetvli zero, a2, e8, m4, ta, mu
; CHECK-NEXT: vle8.v v8, (a0)
-; CHECK-NEXT: vmsgt.vx v12, v8, zero
+; CHECK-NEXT: vmsgt.vi v12, v8, 0
; CHECK-NEXT: vsm.v v12, (a1)
; CHECK-NEXT: ret
%a = load <64 x i8>, <64 x i8>* %x
@@ -564,6 +564,23 @@ define void @setgt_vi_v64i8(<64 x i8>* %x, <64 x i1>* %z) {
ret void
}
+define void @setgt_vi_v64i8_nonzero(<64 x i8>* %x, <64 x i1>* %z) {
+; CHECK-LABEL: setgt_vi_v64i8_nonzero:
+; CHECK: # %bb.0:
+; CHECK-NEXT: li a2, 64
+; CHECK-NEXT: vsetvli zero, a2, e8, m4, ta, mu
+; CHECK-NEXT: vle8.v v8, (a0)
+; CHECK-NEXT: vmsgt.vi v12, v8, 5
+; CHECK-NEXT: vsm.v v12, (a1)
+; CHECK-NEXT: ret
+ %a = load <64 x i8>, <64 x i8>* %x
+ %b = insertelement <64 x i8> undef, i8 5, i32 0
+ %c = shufflevector <64 x i8> %b, <64 x i8> undef, <64 x i32> zeroinitializer
+ %d = icmp sgt <64 x i8> %a, %c
+ store <64 x i1> %d, <64 x i1>* %z
+ ret void
+}
+
define void @setlt_vi_v128i8(<128 x i8>* %x, <128 x i1>* %z) {
; CHECK-LABEL: setlt_vi_v128i8:
; CHECK: # %bb.0:
@@ -619,8 +636,7 @@ define void @setugt_vi_v32i8(<32 x i8>* %x, <32 x i1>* %z) {
; CHECK-NEXT: li a2, 32
; CHECK-NEXT: vsetvli zero, a2, e8, m2, ta, mu
; CHECK-NEXT: vle8.v v8, (a0)
-; CHECK-NEXT: li a0, 5
-; CHECK-NEXT: vmsgtu.vx v10, v8, a0
+; CHECK-NEXT: vmsgtu.vi v10, v8, 5
; CHECK-NEXT: vsm.v v10, (a1)
; CHECK-NEXT: ret
%a = load <32 x i8>, <32 x i8>* %x
More information about the llvm-commits
mailing list