Skip to content

Commit 8c1dc5d

Browse files
committed
[RISCV] Add test for miscompile of vector.interleave when odd vector is literal poison.
The interleave lowering relies on a math trick that requires passing the odd vector to two math instructions. In order to be correct these instructions must see the same value. If the odd vector is provably poison or undef, SelectionDAG will create a vwadd and vwmaccu where the operand is a copy from IMPLICIT_DEF. Later this will become just the undef flag on the operand. This gives the register allocator freedom to pick a different register for each instruction.
1 parent d595080 commit 8c1dc5d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,31 @@ define <vscale x 16 x double> @vector_interleave_nxv16f64_nxv8f64(<vscale x 8 x
656656
ret <vscale x 16 x double> %res
657657
}
658658

659+
; FIXME: The last operand to the vwaddu.vv and vwmaccu.vx are both undef. They
660+
; need to be the same register with the same contents. Otherwise, the even
661+
; elements will not contain just the values from %a.
662+
define <vscale x 8 x i32> @vector_interleave_nxv8i32_nxv4i32_poison(<vscale x 4 x i32> %a) {
663+
; CHECK-LABEL: vector_interleave_nxv8i32_nxv4i32_poison:
664+
; CHECK: # %bb.0:
665+
; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
666+
; CHECK-NEXT: vwaddu.vv v12, v8, v10
667+
; CHECK-NEXT: li a0, -1
668+
; CHECK-NEXT: vwmaccu.vx v12, a0, v8
669+
; CHECK-NEXT: vmv4r.v v8, v12
670+
; CHECK-NEXT: ret
671+
;
672+
; ZVBB-LABEL: vector_interleave_nxv8i32_nxv4i32_poison:
673+
; ZVBB: # %bb.0:
674+
; ZVBB-NEXT: li a0, 32
675+
; ZVBB-NEXT: vsetvli a1, zero, e32, m2, ta, ma
676+
; ZVBB-NEXT: vwsll.vx v12, v10, a0
677+
; ZVBB-NEXT: vwaddu.wv v12, v12, v8
678+
; ZVBB-NEXT: vmv4r.v v8, v12
679+
; ZVBB-NEXT: ret
680+
%res = call <vscale x 8 x i32> @llvm.experimental.vector.interleave2.nxv8i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> poison)
681+
ret <vscale x 8 x i32> %res
682+
}
683+
659684
declare <vscale x 64 x half> @llvm.experimental.vector.interleave2.nxv64f16(<vscale x 32 x half>, <vscale x 32 x half>)
660685
declare <vscale x 32 x float> @llvm.experimental.vector.interleave2.nxv32f32(<vscale x 16 x float>, <vscale x 16 x float>)
661686
declare <vscale x 16 x double> @llvm.experimental.vector.interleave2.nxv16f64(<vscale x 8 x double>, <vscale x 8 x double>)

0 commit comments

Comments
 (0)