Skip to content

Commit 39e9097

Browse files
rotaterighttstellar
authored andcommitted
[InstCombine] add scalable vector test for logical select; NFC
D124997 shows that the code is not ready to handle scalable vectors, so add some more coverage for a potential crashing case. (cherry picked from commit 7bad1d2)
1 parent cd59758 commit 39e9097

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

llvm/test/Transforms/InstCombine/logical-select.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,25 @@ define <2 x i64> @bitcast_vec_cond(<16 x i1> %cond, <2 x i64> %c, <2 x i64> %d)
708708
ret <2 x i64> %r
709709
}
710710

711+
define <vscale x 2 x i64> @bitcast_vec_condi_scalable(<vscale x 16 x i1> %cond, <vscale x 2 x i64> %c, <vscale x 2 x i64> %d) {
712+
; CHECK-LABEL: @bitcast_vec_condi_scalable(
713+
; CHECK-NEXT: [[S:%.*]] = sext <vscale x 16 x i1> [[COND:%.*]] to <vscale x 16 x i8>
714+
; CHECK-NEXT: [[T9:%.*]] = bitcast <vscale x 16 x i8> [[S]] to <vscale x 2 x i64>
715+
; CHECK-NEXT: [[NOTT9:%.*]] = xor <vscale x 2 x i64> [[T9]], shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 -1, i32 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer)
716+
; CHECK-NEXT: [[T11:%.*]] = and <vscale x 2 x i64> [[NOTT9]], [[C:%.*]]
717+
; CHECK-NEXT: [[T12:%.*]] = and <vscale x 2 x i64> [[T9]], [[D:%.*]]
718+
; CHECK-NEXT: [[R:%.*]] = or <vscale x 2 x i64> [[T11]], [[T12]]
719+
; CHECK-NEXT: ret <vscale x 2 x i64> [[R]]
720+
;
721+
%s = sext <vscale x 16 x i1> %cond to <vscale x 16 x i8>
722+
%t9 = bitcast <vscale x 16 x i8> %s to <vscale x 2 x i64>
723+
%nott9 = xor <vscale x 2 x i64> %t9, shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 -1, i32 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer)
724+
%t11 = and <vscale x 2 x i64> %nott9, %c
725+
%t12 = and <vscale x 2 x i64> %t9, %d
726+
%r = or <vscale x 2 x i64> %t11, %t12
727+
ret <vscale x 2 x i64> %r
728+
}
729+
711730
; Negative test - bitcast of condition from wide source element type cannot be converted to select.
712731

713732
define <8 x i3> @bitcast_vec_cond_commute1(<3 x i1> %cond, <8 x i3> %pc, <8 x i3> %d) {

0 commit comments

Comments
 (0)