Skip to content

Commit 98260a1

Browse files
committed
[RISCV] Add reversed select testcase for canSplatOperand [nfc]
1 parent ab0bd34 commit 98260a1

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

llvm/test/CodeGen/RISCV/rvv/sink-splat-operands.ll

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5424,8 +5424,8 @@ for.cond.cleanup: ; preds = %vector.body
54245424
ret void
54255425
}
54265426

5427-
define void @sink_splat_select(ptr nocapture %a, i32 signext %x) {
5428-
; CHECK-LABEL: sink_splat_select:
5427+
define void @sink_splat_select_op1(ptr nocapture %a, i32 signext %x) {
5428+
; CHECK-LABEL: sink_splat_select_op1:
54295429
; CHECK: # %bb.0: # %entry
54305430
; CHECK-NEXT: lui a2, 1
54315431
; CHECK-NEXT: add a2, a0, a2
@@ -5460,3 +5460,41 @@ vector.body: ; preds = %vector.body, %entry
54605460
for.cond.cleanup: ; preds = %vector.body
54615461
ret void
54625462
}
5463+
5464+
define void @sink_splat_select_op2(ptr nocapture %a, i32 signext %x) {
5465+
; CHECK-LABEL: sink_splat_select_op2:
5466+
; CHECK: # %bb.0: # %entry
5467+
; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
5468+
; CHECK-NEXT: vmv.v.x v8, a1
5469+
; CHECK-NEXT: lui a1, 1
5470+
; CHECK-NEXT: add a1, a0, a1
5471+
; CHECK-NEXT: li a2, 42
5472+
; CHECK-NEXT: .LBB118_1: # %vector.body
5473+
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
5474+
; CHECK-NEXT: vle32.v v9, (a0)
5475+
; CHECK-NEXT: vmseq.vx v0, v9, a2
5476+
; CHECK-NEXT: vmerge.vvm v9, v8, v9, v0
5477+
; CHECK-NEXT: vse32.v v9, (a0)
5478+
; CHECK-NEXT: addi a0, a0, 16
5479+
; CHECK-NEXT: bne a0, a1, .LBB118_1
5480+
; CHECK-NEXT: # %bb.2: # %for.cond.cleanup
5481+
; CHECK-NEXT: ret
5482+
entry:
5483+
%broadcast.splatinsert = insertelement <4 x i32> poison, i32 %x, i32 0
5484+
%broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
5485+
br label %vector.body
5486+
5487+
vector.body: ; preds = %vector.body, %entry
5488+
%index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]
5489+
%0 = getelementptr inbounds i32, ptr %a, i64 %index
5490+
%load = load <4 x i32>, ptr %0, align 4
5491+
%cond = icmp eq <4 x i32> %load, splat (i32 42)
5492+
%1 = select <4 x i1> %cond, <4 x i32> %load, <4 x i32> %broadcast.splat
5493+
store <4 x i32> %1, ptr %0, align 4
5494+
%index.next = add nuw i64 %index, 4
5495+
%2 = icmp eq i64 %index.next, 1024
5496+
br i1 %2, label %for.cond.cleanup, label %vector.body
5497+
5498+
for.cond.cleanup: ; preds = %vector.body
5499+
ret void
5500+
}

0 commit comments

Comments
 (0)