Skip to content

Commit 28cf323

Browse files
[LLVM] Port a few InstCombine tests to use splat instead of shufflevector.
1 parent 0ba2000 commit 28cf323

File tree

6 files changed

+24
-39
lines changed

6 files changed

+24
-39
lines changed

llvm/test/Transforms/InstCombine/scalable-const-fp-splat.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ define <vscale x 2 x float> @shrink_splat_scalable_extend(<vscale x 2 x float> %
77
; CHECK-NEXT: [[TMP1:%.*]] = fadd <vscale x 2 x float> [[A]], splat (float -1.000000e+00)
88
; CHECK-NEXT: ret <vscale x 2 x float> [[TMP1]]
99
;
10-
%1 = shufflevector <vscale x 2 x float> insertelement (<vscale x 2 x float> undef, float -1.000000e+00, i32 0), <vscale x 2 x float> undef, <vscale x 2 x i32> zeroinitializer
1110
%2 = fpext <vscale x 2 x float> %a to <vscale x 2 x double>
12-
%3 = fpext <vscale x 2 x float> %1 to <vscale x 2 x double>
11+
%3 = fpext <vscale x 2 x float> splat (float -1.000000e+00) to <vscale x 2 x double>
1312
%4 = fadd <vscale x 2 x double> %2, %3
1413
%5 = fptrunc <vscale x 2 x double> %4 to <vscale x 2 x float>
1514
ret <vscale x 2 x float> %5

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ define <vscale x 1 x i32> @select_opt(<vscale x 1 x i32> %b, <vscale x 1 x i1> %
99
; CHECK-NEXT: [[D:%.*]] = select <vscale x 1 x i1> [[M:%.*]], <vscale x 1 x i32> [[C]], <vscale x 1 x i32> [[B]]
1010
; CHECK-NEXT: ret <vscale x 1 x i32> [[D]]
1111
;
12-
%head = insertelement <vscale x 1 x i32> undef, i32 2, i32 0
13-
%splat = shufflevector <vscale x 1 x i32> %head, <vscale x 1 x i32> undef, <vscale x 1 x i32> zeroinitializer
14-
%c = add nsw <vscale x 1 x i32> %b, %splat
12+
%c = add nsw <vscale x 1 x i32> %b, splat (i32 2)
1513
%d = select <vscale x 1 x i1> %m, <vscale x 1 x i32> %c, <vscale x 1 x i32> %b
1614
ret <vscale x 1 x i32> %d
1715
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ define <vscale x 2 x i32> @masked_gather_and_zero_inactive_4(<vscale x 2 x ptr>
4242
; CHECK-NEXT: [[GATHER:%.*]] = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32.nxv2p0(<vscale x 2 x ptr> [[PTR:%.*]], i32 4, <vscale x 2 x i1> [[MASK]], <vscale x 2 x i32> zeroinitializer)
4343
; CHECK-NEXT: ret <vscale x 2 x i32> [[GATHER]]
4444
;
45-
%splat = shufflevector <vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
46-
%mask = xor <vscale x 2 x i1> %inv_mask, %splat
45+
%mask = xor <vscale x 2 x i1> %inv_mask, splat (i1 true)
4746
%gather = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32(<vscale x 2 x ptr> %ptr, i32 4, <vscale x 2 x i1> %mask, <vscale x 2 x i32> undef)
4847
%masked = select <vscale x 2 x i1> %inv_mask, <vscale x 2 x i32> zeroinitializer, <vscale x 2 x i32> %gather
4948
ret <vscale x 2 x i32> %masked
@@ -56,8 +55,7 @@ define <vscale x 2 x i32> @masked_gather_and_zero_inactive_5(<vscale x 2 x ptr>
5655
; CHECK-NEXT: [[GATHER:%.*]] = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32.nxv2p0(<vscale x 2 x ptr> [[PTR:%.*]], i32 4, <vscale x 2 x i1> [[MASK]], <vscale x 2 x i32> zeroinitializer)
5756
; CHECK-NEXT: ret <vscale x 2 x i32> [[GATHER]]
5857
;
59-
%splat = shufflevector <vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
60-
%mask = xor <vscale x 2 x i1> %inv_mask, %splat
58+
%mask = xor <vscale x 2 x i1> %inv_mask, splat (i1 true)
6159
%gather = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32(<vscale x 2 x ptr> %ptr, i32 4, <vscale x 2 x i1> %mask, <vscale x 2 x i32> zeroinitializer)
6260
%masked = select <vscale x 2 x i1> %inv_mask, <vscale x 2 x i32> zeroinitializer, <vscale x 2 x i32> %gather
6361
ret <vscale x 2 x i32> %masked
@@ -71,8 +69,7 @@ define <vscale x 2 x i32> @masked_gather_and_zero_inactive_6(<vscale x 2 x ptr>
7169
; CHECK-NEXT: [[MASKED:%.*]] = select <vscale x 2 x i1> [[INV_MASK]], <vscale x 2 x i32> zeroinitializer, <vscale x 2 x i32> [[GATHER]]
7270
; CHECK-NEXT: ret <vscale x 2 x i32> [[MASKED]]
7371
;
74-
%splat = shufflevector <vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
75-
%mask = xor <vscale x 2 x i1> %inv_mask, %splat
72+
%mask = xor <vscale x 2 x i1> %inv_mask, splat (i1 true)
7673
%gather = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32(<vscale x 2 x ptr> %ptr, i32 4, <vscale x 2 x i1> %mask, <vscale x 2 x i32> %passthrough)
7774
%masked = select <vscale x 2 x i1> %inv_mask, <vscale x 2 x i32> zeroinitializer, <vscale x 2 x i32> %gather
7875
ret <vscale x 2 x i32> %masked
@@ -99,8 +96,7 @@ define <vscale x 2 x float> @masked_gather_and_zero_inactive_8(<vscale x 2 x ptr
9996
; CHECK-NEXT: [[GATHER:%.*]] = call <vscale x 2 x float> @llvm.masked.gather.nxv2f32.nxv2p0(<vscale x 2 x ptr> [[PTR:%.*]], i32 4, <vscale x 2 x i1> [[PG]], <vscale x 2 x float> zeroinitializer)
10097
; CHECK-NEXT: ret <vscale x 2 x float> [[GATHER]]
10198
;
102-
%splat = shufflevector <vscale x 2 x i1> insertelement (<vscale x 2 x i1> undef, i1 true, i32 0), <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
103-
%mask = xor <vscale x 2 x i1> %inv_mask, %splat
99+
%mask = xor <vscale x 2 x i1> %inv_mask, splat (i1 true)
104100
%pg = and <vscale x 2 x i1> %mask, %cond
105101
%gather = call <vscale x 2 x float> @llvm.masked.gather.nxv2f32(<vscale x 2 x ptr> %ptr, i32 4, <vscale x 2 x i1> %pg, <vscale x 2 x float> undef)
106102
%masked = select <vscale x 2 x i1> %inv_mask, <vscale x 2 x float> zeroinitializer, <vscale x 2 x float> %gather
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
12
; RUN: opt -passes=instcombine -S < %s | FileCheck %s
23

3-
; This vscale udiv with a power-of-2 spalt on the rhs should not crash opt
4+
; This vscale udiv with a power-of-2 splat on the rhs should not crash opt
45

5-
; CHECK: define <vscale x 2 x i32> @udiv_pow2_vscale(<vscale x 2 x i32> %lhs)
66
define <vscale x 2 x i32> @udiv_pow2_vscale(<vscale x 2 x i32> %lhs) {
7-
%splatter = insertelement <vscale x 2 x i32> undef, i32 2, i32 0
8-
%rhs = shufflevector <vscale x 2 x i32> %splatter,
9-
<vscale x 2 x i32> undef,
10-
<vscale x 2 x i32> zeroinitializer
11-
%res = udiv <vscale x 2 x i32> %lhs, %rhs
7+
; CHECK-LABEL: define <vscale x 2 x i32> @udiv_pow2_vscale(
8+
; CHECK-SAME: <vscale x 2 x i32> [[LHS:%.*]]) {
9+
; CHECK-NEXT: [[RES1:%.*]] = lshr <vscale x 2 x i32> [[LHS]], splat (i32 1)
10+
; CHECK-NEXT: ret <vscale x 2 x i32> [[RES1]]
11+
;
12+
%res = udiv <vscale x 2 x i32> %lhs, splat (i32 2)
1213
ret <vscale x 2 x i32> %res
1314
}
1415

1516
; This fixed width udiv with a power-of-2 splat on the rhs should also not
1617
; crash, and instcombine should eliminate the udiv
1718

18-
; CHECK-LABEL: define <2 x i32> @udiv_pow2_fixed(<2 x i32> %lhs)
19-
; CHECK-NOT: udiv
2019
define <2 x i32> @udiv_pow2_fixed(<2 x i32> %lhs) {
21-
%splatter = insertelement <2 x i32> undef, i32 2, i32 0
22-
%rhs = shufflevector <2 x i32> %splatter,
23-
<2 x i32> undef,
24-
<2 x i32> zeroinitializer
25-
%res = udiv <2 x i32> %lhs, %rhs
20+
; CHECK-LABEL: define <2 x i32> @udiv_pow2_fixed(
21+
; CHECK-SAME: <2 x i32> [[LHS:%.*]]) {
22+
; CHECK-NEXT: [[RES1:%.*]] = lshr <2 x i32> [[LHS]], splat (i32 1)
23+
; CHECK-NEXT: ret <2 x i32> [[RES1]]
24+
;
25+
%res = udiv <2 x i32> %lhs, splat (i32 2)
2626
ret <2 x i32> %res
2727
}

llvm/test/Transforms/InstCombine/vector_gep1.ll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ define <vscale x 2 x i1> @test8() {
6666
; CHECK-LABEL: @test8(
6767
; CHECK-NEXT: ret <vscale x 2 x i1> zeroinitializer
6868
;
69-
%ins = insertelement <vscale x 2 x i32> undef, i32 1, i32 0
70-
%b = shufflevector <vscale x 2 x i32> %ins, <vscale x 2 x i32> undef, <vscale x 2 x i32> zeroinitializer
71-
%c = inttoptr <vscale x 2 x i32> %b to <vscale x 2 x ptr>
69+
%c = inttoptr <vscale x 2 x i32> splat (i32 1) to <vscale x 2 x ptr>
7270
%d = icmp ult <vscale x 2 x ptr> %c, zeroinitializer
7371
ret <vscale x 2 x i1> %d
7472
}

llvm/test/Transforms/InstSimplify/ConstProp/extractelement-vscale.ll

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ define i32 @extractconstant_shuffle_in_range(i32 %v) {
2222
; CHECK-SAME: i32 [[V:%.*]]) {
2323
; CHECK-NEXT: ret i32 1024
2424
;
25-
%in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
26-
%splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
27-
%r = extractelement <vscale x 4 x i32> %splat, i32 1
25+
%r = extractelement <vscale x 4 x i32> splat (i32 1024), i32 1
2826
ret i32 %r
2927
}
3028

@@ -33,9 +31,7 @@ define i32 @extractconstant_shuffle_maybe_out_of_range(i32 %v) {
3331
; CHECK-SAME: i32 [[V:%.*]]) {
3432
; CHECK-NEXT: ret i32 extractelement (<vscale x 4 x i32> splat (i32 1024), i32 4)
3533
;
36-
%in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
37-
%splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
38-
%r = extractelement <vscale x 4 x i32> %splat, i32 4
34+
%r = extractelement <vscale x 4 x i32> splat (i32 1024), i32 4
3935
ret i32 %r
4036
}
4137

@@ -44,8 +40,6 @@ define i32 @extractconstant_shuffle_invalid_index(i32 %v) {
4440
; CHECK-SAME: i32 [[V:%.*]]) {
4541
; CHECK-NEXT: ret i32 extractelement (<vscale x 4 x i32> splat (i32 1024), i32 -1)
4642
;
47-
%in = insertelement <vscale x 4 x i32> undef, i32 1024, i32 0
48-
%splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
49-
%r = extractelement <vscale x 4 x i32> %splat, i32 -1
43+
%r = extractelement <vscale x 4 x i32> splat (i32 1024), i32 -1
5044
ret i32 %r
5145
}

0 commit comments

Comments
 (0)