Skip to content

Commit c8d431e

Browse files
committed
[riscv] Add test coverage in advance of a upcoming fix
This is a reduced test case for a fix for the issue identified in llvm#80910.
1 parent bef25ae commit c8d431e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-buildvec-of-binop.ll

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,3 +588,37 @@ define <8 x i32> @add_constant_rhs_8xi32_partial(<8 x i32> %vin, i32 %a, i32 %b,
588588
%v3 = insertelement <8 x i32> %v2, i32 %e3, i32 7
589589
ret <8 x i32> %v3
590590
}
591+
592+
; FIXME: This is currently showing a miscompile, we effectively
593+
; truncate before the ashr instead of after it, so if %a or %b
594+
; is e.g. UINT32_MAX+1 we get different result.
595+
define <2 x i32> @build_vec_of_trunc_op(i64 %a, i64 %b) {
596+
; RV32-LABEL: build_vec_of_trunc_op:
597+
; RV32: # %bb.0: # %entry
598+
; RV32-NEXT: slli a1, a1, 31
599+
; RV32-NEXT: srli a0, a0, 1
600+
; RV32-NEXT: or a0, a0, a1
601+
; RV32-NEXT: slli a3, a3, 31
602+
; RV32-NEXT: srli a2, a2, 1
603+
; RV32-NEXT: or a2, a2, a3
604+
; RV32-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
605+
; RV32-NEXT: vmv.v.x v8, a0
606+
; RV32-NEXT: vslide1down.vx v8, v8, a2
607+
; RV32-NEXT: ret
608+
;
609+
; RV64-LABEL: build_vec_of_trunc_op:
610+
; RV64: # %bb.0: # %entry
611+
; RV64-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
612+
; RV64-NEXT: vmv.v.x v8, a0
613+
; RV64-NEXT: vslide1down.vx v8, v8, a1
614+
; RV64-NEXT: vsrl.vi v8, v8, 1
615+
; RV64-NEXT: ret
616+
entry:
617+
%conv11.i = ashr i64 %a, 1
618+
%conv11.2 = ashr i64 %b, 1
619+
%0 = trunc i64 %conv11.i to i32
620+
%1 = trunc i64 %conv11.2 to i32
621+
%2 = insertelement <2 x i32> zeroinitializer, i32 %0, i64 0
622+
%3 = insertelement <2 x i32> %2, i32 %1, i64 1
623+
ret <2 x i32> %3
624+
}

0 commit comments

Comments
 (0)