diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -3082,8 +3082,8 @@ if (!ShuffleVectorInst::isInterleaveMask(Mask, 2, Size * 2, StartIndexes)) return false; - EvenSrc = StartIndexes[0] % 2 ? StartIndexes[1] : StartIndexes[0]; - OddSrc = StartIndexes[0] % 2 ? StartIndexes[0] : StartIndexes[1]; + EvenSrc = StartIndexes[0]; + OddSrc = StartIndexes[1]; // One source should be low half of first vector. if (EvenSrc != 0 && OddSrc != 0) diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-interleave.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-interleave.ll --- a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-interleave.ll +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-interleave.ll @@ -665,17 +665,16 @@ } ; This interleaves the first 2 elements of a vector in opposite order. With -; undefs for the remaining elements. -; FIXME: We incorrectly swap the elements. +; undefs for the remaining elements. We use to miscompile this. define <4 x i8> @unary_interleave_10uu_v4i8(<4 x i8> %x) { ; V128-LABEL: unary_interleave_10uu_v4i8: ; V128: # %bb.0: ; V128-NEXT: vsetivli zero, 2, e8, mf4, ta, ma ; V128-NEXT: vslidedown.vi v10, v8, 1 ; V128-NEXT: vsetivli zero, 2, e8, mf8, ta, ma -; V128-NEXT: vwaddu.vv v9, v8, v10 +; V128-NEXT: vwaddu.vv v9, v10, v8 ; V128-NEXT: li a0, -1 -; V128-NEXT: vwmaccu.vx v9, a0, v10 +; V128-NEXT: vwmaccu.vx v9, a0, v8 ; V128-NEXT: vmv1r.v v8, v9 ; V128-NEXT: ret ; @@ -683,9 +682,9 @@ ; V512: # %bb.0: ; V512-NEXT: vsetivli zero, 2, e8, mf8, ta, ma ; V512-NEXT: vslidedown.vi v10, v8, 1 -; V512-NEXT: vwaddu.vv v9, v8, v10 +; V512-NEXT: vwaddu.vv v9, v10, v8 ; V512-NEXT: li a0, -1 -; V512-NEXT: vwmaccu.vx v9, a0, v10 +; V512-NEXT: vwmaccu.vx v9, a0, v8 ; V512-NEXT: vmv1r.v v8, v9 ; V512-NEXT: ret %a = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32>