[PATCH] D113649: [RISCV] Teach VSETVLI insertion to handle mask instruction which has avl from a PHI node.
Jianjian Guan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 10 23:32:17 PST 2021
jacquesguan created this revision.
jacquesguan added reviewers: craig.topper, HsiangKai, khchen, asb, luismarques, frasercrmck.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
jacquesguan requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Use hasCompatibleVTYPE instead of hasSameVTYPE in needVSETVLIPHI, in order to avoid insert a vsetvli for mask instruction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113649
Files:
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll
Index: llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll
===================================================================
--- llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll
+++ llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll
@@ -98,24 +98,23 @@
define void @test6(i32* nocapture readonly %A, i32* nocapture %B, i64 %n) {
; CHECK-LABEL: test6:
; CHECK: # %bb.0: # %entry
-; CHECK-NEXT: vsetvli a3, a2, e32, m1, ta, mu
-; CHECK-NEXT: beqz a3, .LBB5_3
+; CHECK-NEXT: vsetvli a6, a2, e32, m1, ta, mu
+; CHECK-NEXT: beqz a6, .LBB5_3
; CHECK-NEXT: # %bb.1: # %for.body.preheader
; CHECK-NEXT: mv a4, zero
; CHECK-NEXT: .LBB5_2: # %for.body
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
-; CHECK-NEXT: slli a6, a4, 2
-; CHECK-NEXT: add a5, a0, a6
-; CHECK-NEXT: vle32.v v8, (a5)
+; CHECK-NEXT: slli a5, a4, 2
+; CHECK-NEXT: add a3, a0, a5
+; CHECK-NEXT: vle32.v v8, (a3)
; CHECK-NEXT: vmsle.vi v9, v8, -3
; CHECK-NEXT: vmsgt.vi v10, v8, 2
-; CHECK-NEXT: vsetvli zero, a3, e8, mf4, ta, mu
; CHECK-NEXT: vmor.mm v0, v9, v10
-; CHECK-NEXT: add a5, a1, a6
-; CHECK-NEXT: vse32.v v8, (a5), v0.t
-; CHECK-NEXT: add a4, a4, a3
-; CHECK-NEXT: vsetvli a3, a2, e32, m1, ta, mu
-; CHECK-NEXT: bnez a3, .LBB5_2
+; CHECK-NEXT: add a3, a1, a5
+; CHECK-NEXT: vse32.v v8, (a3), v0.t
+; CHECK-NEXT: add a4, a4, a6
+; CHECK-NEXT: vsetvli a6, a2, e32, m1, ta, mu
+; CHECK-NEXT: bnez a6, .LBB5_2
; CHECK-NEXT: .LBB5_3: # %for.cond.cleanup
; CHECK-NEXT: ret
entry:
Index: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -900,7 +900,8 @@
const BlockData &PBBInfo = BlockInfo[PBB->getNumber()];
// If the exit from the predecessor has the VTYPE we are looking for
// we might be able to avoid a VSETVLI.
- if (PBBInfo.Exit.isUnknown() || !PBBInfo.Exit.hasSameVTYPE(Require))
+ if (PBBInfo.Exit.isUnknown() ||
+ !PBBInfo.Exit.hasCompatibleVTYPE(Require, false))
return true;
// We need the PHI input to the be the output of a VSET(I)VLI.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113649.386428.patch
Type: text/x-patch
Size: 2218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/feed5538/attachment.bin>
More information about the llvm-commits
mailing list