[llvm] 5cf9f2c - [RISCV] Fix M1 shuffle on wrong SrcVec in lowerShuffleViaVRegSplitting
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 07:36:11 PST 2024
Thank you for catching this!
Philip
On 1/26/24 05:25, Luke Lau via llvm-commits wrote:
> Author: Luke Lau
> Date: 2024-01-26T20:25:05+07:00
> New Revision: 5cf9f2cd9888feea23a624c1de3cc37ce8ce8112
>
> URL: https://github.com/llvm/llvm-project/commit/5cf9f2cd9888feea23a624c1de3cc37ce8ce8112
> DIFF: https://github.com/llvm/llvm-project/commit/5cf9f2cd9888feea23a624c1de3cc37ce8ce8112.diff
>
> LOG: [RISCV] Fix M1 shuffle on wrong SrcVec in lowerShuffleViaVRegSplitting
>
> This fixes a miscompile from #79072 where we were taking the wrong SrcVec to do
> the M1 shuffle. E.g. if the SrcVecIdx was 2 and we had 2 VRegsPerSrc, we ended
> up taking it from V1 instead of V2.
>
> Added:
>
>
> Modified:
> llvm/lib/Target/RISCV/RISCVISelLowering.cpp
> llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-exact-vlen.ll
>
> Removed:
>
>
>
> ################################################################################
> diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
> index 0cfadfbdb89b4e..5b1a246a19c8e8 100644
> --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
> +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
> @@ -4745,7 +4745,7 @@ static SDValue lowerShuffleViaVRegSplitting(ShuffleVectorSDNode *SVN,
> if (SrcVecIdx == -1)
> continue;
> unsigned ExtractIdx = (SrcVecIdx % VRegsPerSrc) * NumOpElts;
> - SDValue SrcVec = (unsigned)SrcVecIdx > VRegsPerSrc ? V2 : V1;
> + SDValue SrcVec = (unsigned)SrcVecIdx >= VRegsPerSrc ? V2 : V1;
> SDValue SubVec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, M1VT, SrcVec,
> DAG.getVectorIdxConstant(ExtractIdx, DL));
> SubVec = convertFromScalableVector(OneRegVT, SubVec, DAG, Subtarget);
>
> diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-exact-vlen.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-exact-vlen.ll
> index b2b6e3b4414b1f..8499086994bc01 100644
> --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-exact-vlen.ll
> +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-exact-vlen.ll
> @@ -149,15 +149,13 @@ define <4 x i64> @m2_splat_into_identity_two_source_v2_hi(<4 x i64> %v1, <4 x i6
> ret <4 x i64> %res
> }
>
> -; FIXME: This is a miscompile, we're clobbering the lower reg group of %v2
> -; (v10), and the vmv1r.v is moving from the wrong reg group (should be v10)
> define <4 x i64> @m2_splat_into_slide_two_source_v2_lo(<4 x i64> %v1, <4 x i64> %v2) vscale_range(2,2) {
> ; CHECK-LABEL: m2_splat_into_slide_two_source_v2_lo:
> ; CHECK: # %bb.0:
> ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
> -; CHECK-NEXT: vrgather.vi v10, v8, 0
> -; CHECK-NEXT: vmv1r.v v11, v8
> -; CHECK-NEXT: vmv2r.v v8, v10
> +; CHECK-NEXT: vrgather.vi v12, v8, 0
> +; CHECK-NEXT: vmv1r.v v13, v10
> +; CHECK-NEXT: vmv2r.v v8, v12
> ; CHECK-NEXT: ret
> %res = shufflevector <4 x i64> %v1, <4 x i64> %v2, <4 x i32> <i32 0, i32 0, i32 4, i32 5>
> ret <4 x i64> %res
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list