Skip to content

Commit 627e210

Browse files
committed
[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
1 parent f4a3569 commit 627e210

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
@@ -745,3 +745,18 @@ define <4 x i8> @buildvec_not_vid_v4i8_2() {
745745
; CHECK-NEXT: ret
746746
ret <4 x i8> <i8 3, i8 3, i8 1, i8 0>
747747
}
748+
749+
; FIXME: This is not a valid way to emit this vid sequence: shift-right for
750+
; division only works for non-negative numbers!
751+
define <16 x i8> @buildvec_not_vid_v16i8() {
752+
; CHECK-LABEL: buildvec_not_vid_v16i8:
753+
; CHECK: # %bb.0:
754+
; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, mu
755+
; CHECK-NEXT: vid.v v8
756+
; CHECK-NEXT: li a0, -3
757+
; CHECK-NEXT: vmul.vx v8, v8, a0
758+
; CHECK-NEXT: vsrl.vi v8, v8, 3
759+
; CHECK-NEXT: vadd.vi v8, v8, 5
760+
; CHECK-NEXT: ret
761+
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>
762+
}

0 commit comments

Comments
 (0)