Skip to content

Commit e19be41

Browse files
frasercrmcktstellar
authored andcommitted
[RISCV] Add another test showing incorrect BUILD_VECTOR lowering
This test shows a (contrived) BUILD_VECTOR which is correctly identified as a sequence of ((vid * -3) / 8) + 5. However, the issue is that using shift-right for the divide is invalid as the step values are negative. This patch just adds the test: the fix is added in D123796. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D123989 (cherry picked from commit 627e210)
1 parent 9efcce9 commit e19be41

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,3 +726,18 @@ define <4 x i8> @buildvec_not_vid_v4i8_2() {
726726
; CHECK-NEXT: ret
727727
ret <4 x i8> <i8 3, i8 3, i8 1, i8 0>
728728
}
729+
730+
; FIXME: This is not a valid way to emit this vid sequence: shift-right for
731+
; division only works for non-negative numbers!
732+
define <16 x i8> @buildvec_not_vid_v16i8() {
733+
; CHECK-LABEL: buildvec_not_vid_v16i8:
734+
; CHECK: # %bb.0:
735+
; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, mu
736+
; CHECK-NEXT: vid.v v8
737+
; CHECK-NEXT: li a0, -3
738+
; CHECK-NEXT: vmul.vx v8, v8, a0
739+
; CHECK-NEXT: vsrl.vi v8, v8, 3
740+
; CHECK-NEXT: vadd.vi v8, v8, 5
741+
; CHECK-NEXT: ret
742+
ret <16 x i8> <i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 3, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 0, i8 0>
743+
}

0 commit comments

Comments
 (0)