Skip to content

Commit f65b329

Browse files
committed
[IA] Fix a bug introduced by a recent refactoring
I had dropped the check for which intrinsics were supported. This is a quick fix to get tree back into an unbroken state, a cleaner change may follow.
1 parent d50a4f6 commit f65b329

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

llvm/lib/CodeGen/InterleavedAccessPass.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ bool InterleavedAccessImpl::lowerDeinterleaveIntrinsic(
634634
<< " and factor = " << Factor << "\n");
635635
} else {
636636
assert(II);
637+
if (II->getIntrinsicID() != Intrinsic::masked_load &&
638+
II->getIntrinsicID() != Intrinsic::vp_load)
639+
return false;
637640

638641
// Check mask operand. Handle both all-true/false and interleaved mask.
639642
Mask = getMask(getMaskOperand(II), Factor, getDeinterleavedVectorType(DI));
@@ -673,6 +676,9 @@ bool InterleavedAccessImpl::lowerInterleaveIntrinsic(
673676

674677
Value *Mask = nullptr;
675678
if (II) {
679+
if (II->getIntrinsicID() != Intrinsic::masked_store &&
680+
II->getIntrinsicID() != Intrinsic::vp_store)
681+
return false;
676682
// Check mask operand. Handle both all-true/false and interleaved mask.
677683
Mask = getMask(getMaskOperand(II), Factor,
678684
cast<VectorType>(InterleaveValues[0]->getType()));

llvm/test/CodeGen/RISCV/rvv/vector-deinterleave-load.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,19 @@ define {<vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i
634634
%deinterleaved.results = call {<vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>} @llvm.vector.deinterleave4.nxv32i8(<vscale x 32 x i8> %vec)
635635
ret {<vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>, <vscale x 8 x i8>} %deinterleaved.results
636636
}
637+
638+
define { <8 x float>, <8 x float> } @deinterleave_unrelated(<16 x float> %arg) {
639+
; CHECK-LABEL: deinterleave_unrelated:
640+
; CHECK: # %bb.0: # %entry
641+
; CHECK-NEXT: vsetivli zero, 16, e32, m4, ta, ma
642+
; CHECK-NEXT: vfabs.v v12, v8
643+
; CHECK-NEXT: li a0, 32
644+
; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
645+
; CHECK-NEXT: vnsrl.wx v10, v12, a0
646+
; CHECK-NEXT: vnsrl.wi v8, v12, 0
647+
; CHECK-NEXT: ret
648+
entry:
649+
%abs = call <16 x float> @llvm.fabs(<16 x float> %arg)
650+
%res = call { <8 x float>, <8 x float> } @llvm.vector.deinterleave2.v16f32(<16 x float> %abs)
651+
ret { <8 x float>, <8 x float> } %res
652+
}

llvm/test/CodeGen/RISCV/rvv/vector-deinterleave.ll

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,3 +3744,61 @@ define <vscale x 1 x float> @vector_deinterleave_nxv1f32_nxv8f32_oneactive2(<vsc
37443744
%ext = extractvalue {<vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>, <vscale x 1 x float>} %res, 5
37453745
ret <vscale x 1 x float> %ext
37463746
}
3747+
3748+
3749+
define { <8 x float>, <8 x float> } @interleave_deinterleave2(<8 x float> %a, <8 x float> %b) {
3750+
; V-LABEL: interleave_deinterleave2:
3751+
; V: # %bb.0: # %entry
3752+
; V-NEXT: vsetivli zero, 8, e32, m2, ta, ma
3753+
; V-NEXT: vwaddu.vv v12, v8, v10
3754+
; V-NEXT: li a0, -1
3755+
; V-NEXT: vwmaccu.vx v12, a0, v10
3756+
; V-NEXT: li a0, 32
3757+
; V-NEXT: vnsrl.wx v10, v12, a0
3758+
; V-NEXT: vnsrl.wi v8, v12, 0
3759+
; V-NEXT: ret
3760+
;
3761+
; ZIP-LABEL: interleave_deinterleave2:
3762+
; ZIP: # %bb.0: # %entry
3763+
; ZIP-NEXT: vsetivli zero, 16, e32, m4, ta, ma
3764+
; ZIP-NEXT: vmv2r.v v12, v10
3765+
; ZIP-NEXT: li a0, 32
3766+
; ZIP-NEXT: ri.vzip2a.vv v16, v8, v12
3767+
; ZIP-NEXT: vsetivli zero, 8, e32, m2, ta, ma
3768+
; ZIP-NEXT: vnsrl.wx v10, v16, a0
3769+
; ZIP-NEXT: vnsrl.wi v8, v16, 0
3770+
; ZIP-NEXT: ret
3771+
entry:
3772+
%0 = call <16 x float> @llvm.vector.interleave2.v16f32(<8 x float> %a, <8 x float> %b)
3773+
%1 = call { <8 x float>, <8 x float> } @llvm.vector.deinterleave2.v16f32(<16 x float> %0)
3774+
ret { <8 x float>, <8 x float> } %1
3775+
}
3776+
3777+
define <16 x float> @deinterleave_interleave2(<16 x float> %arg) {
3778+
; V-LABEL: deinterleave_interleave2:
3779+
; V: # %bb.0: # %entry
3780+
; V-NEXT: li a0, 32
3781+
; V-NEXT: vsetivli zero, 8, e32, m2, ta, ma
3782+
; V-NEXT: vnsrl.wi v12, v8, 0
3783+
; V-NEXT: vnsrl.wx v14, v8, a0
3784+
; V-NEXT: vwaddu.vv v8, v12, v14
3785+
; V-NEXT: li a0, -1
3786+
; V-NEXT: vwmaccu.vx v8, a0, v14
3787+
; V-NEXT: ret
3788+
;
3789+
; ZIP-LABEL: deinterleave_interleave2:
3790+
; ZIP: # %bb.0: # %entry
3791+
; ZIP-NEXT: vsetivli zero, 8, e32, m2, ta, ma
3792+
; ZIP-NEXT: vnsrl.wi v12, v8, 0
3793+
; ZIP-NEXT: li a0, 32
3794+
; ZIP-NEXT: vnsrl.wx v16, v8, a0
3795+
; ZIP-NEXT: vsetivli zero, 16, e32, m4, ta, ma
3796+
; ZIP-NEXT: ri.vzip2a.vv v8, v12, v16
3797+
; ZIP-NEXT: ret
3798+
entry:
3799+
%0 = call { <8 x float>, <8 x float> } @llvm.vector.deinterleave2.v16f32(<16 x float> %arg)
3800+
%a = extractvalue { <8 x float>, <8 x float> } %0, 0
3801+
%b = extractvalue { <8 x float>, <8 x float> } %0, 1
3802+
%res = call <16 x float> @llvm.vector.interleave2.v16f32(<8 x float> %a, <8 x float> %b)
3803+
ret <16 x float> %res
3804+
}

0 commit comments

Comments
 (0)