llvm.org GIT mirror llvm / b3834e5
AMDGPU/GlobalISel: Make some G_MERGE_VALUEs legal git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327267 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 2 years ago
3 changed file(s) with 174 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
118118 (Ty1.getSizeInBits() % 32 == 0);
119119 });
120120
121 // Merge/Unmerge
122 for (unsigned Op : {G_MERGE_VALUES, G_UNMERGE_VALUES}) {
123 unsigned BigTyIdx = Op == G_MERGE_VALUES ? 0 : 1;
124 unsigned LitTyIdx = Op == G_MERGE_VALUES ? 1 : 0;
125
126 getActionDefinitionsBuilder(Op)
127 .legalIf([=](const LegalityQuery &Query) {
128 const LLT &BigTy = Query.Types[BigTyIdx];
129 const LLT &LitTy = Query.Types[LitTyIdx];
130 return BigTy.getSizeInBits() % 32 == 0 &&
131 LitTy.getSizeInBits() % 32 == 0 &&
132 BigTy.getSizeInBits() <= 512;
133 })
134 // Any vectors left are the wrong size. Scalarize them.
135 .fewerElementsIf([](const LegalityQuery &Query) { return true; },
136 [](const LegalityQuery &Query) {
137 return std::make_pair(
138 0, Query.Types[0].getElementType());
139 })
140 .fewerElementsIf([](const LegalityQuery &Query) { return true; },
141 [](const LegalityQuery &Query) {
142 return std::make_pair(
143 1, Query.Types[1].getElementType());
144 });
145
146 }
147
121148 computeTables();
122149 }
0 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
1 # RUN: llc -mtriple=amdgcn-- -O0 -run-pass=legalizer -global-isel %s | FileCheck %s
2
3 ---
4 name: test_merge_s32_s32_s64
5 body: |
6 bb.0:
7 ; CHECK-LABEL: name: test_merge_s32_s32_s64
8 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
9 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
10 ; CHECK: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[C]](s32), [[C1]](s32)
11 ; CHECK: $vgpr0_vgpr1 = COPY [[MV]](s64)
12 %0:_(s32) = G_CONSTANT i32 0
13 %1:_(s32) = G_CONSTANT i32 1
14 %2:_(s64) = G_MERGE_VALUES %0:_(s32), %1:_(s32)
15 $vgpr0_vgpr1 = COPY %2(s64)
16 ...
17
18 ---
19 name: test_merge_s32_s32_v2s32
20 body: |
21 bb.0:
22 ; CHECK-LABEL: name: test_merge_s32_s32_v2s32
23 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
24 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
25 ; CHECK: [[MV:%[0-9]+]]:_(<2 x s32>) = G_MERGE_VALUES [[C]](s32), [[C1]](s32)
26 ; CHECK: $vgpr0_vgpr1 = COPY [[MV]](<2 x s32>)
27 %0:_(s32) = G_CONSTANT i32 0
28 %1:_(s32) = G_CONSTANT i32 1
29 %2:_(<2 x s32>) = G_MERGE_VALUES %0:_(s32), %1:_(s32)
30 $vgpr0_vgpr1 = COPY %2(<2 x s32>)
31 ...
32
33 ---
34 name: test_merge_s32_s32_s32_v3s32
35 body: |
36 bb.0:
37 ; CHECK-LABEL: name: test_merge_s32_s32_s32_v3s32
38 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
39 ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
40 ; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
41 ; CHECK: [[MV:%[0-9]+]]:_(<3 x s32>) = G_MERGE_VALUES [[C]](s32), [[C1]](s32), [[C2]](s32)
42 ; CHECK: $vgpr0_vgpr1_vgpr2 = COPY [[MV]](<3 x s32>)
43 %0:_(s32) = G_CONSTANT i32 0
44 %1:_(s32) = G_CONSTANT i32 1
45 %2:_(s32) = G_CONSTANT i32 2
46 %3:_(<3 x s32>) = G_MERGE_VALUES %0:_(s32), %1:_(s32), %2:_(s32)
47 $vgpr0_vgpr1_vgpr2 = COPY %3(<3 x s32>)
48 ...
49
50 ---
51 name: test_merge_s64_s64_s128
52 body: |
53 bb.0:
54 ; CHECK-LABEL: name: test_merge_s64_s64_s128
55 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
56 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
57 ; CHECK: [[MV:%[0-9]+]]:_(<2 x s64>) = G_MERGE_VALUES [[C]](s64), [[C1]](s64)
58 ; CHECK: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[MV]](<2 x s64>)
59 %0:_(s64) = G_CONSTANT i64 0
60 %1:_(s64) = G_CONSTANT i64 1
61 %2:_(<2 x s64>) = G_MERGE_VALUES %0(s64), %1(s64)
62 $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %2(<2 x s64>)
63 ...
64
65 ---
66 name: test_merge_s64_s64_s64_s64_v4s64
67 body: |
68 bb.0:
69 ; CHECK-LABEL: name: test_merge_s64_s64_s64_s64_v4s64
70 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
71 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
72 ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
73 ; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 3
74 ; CHECK: [[MV:%[0-9]+]]:_(<4 x s64>) = G_MERGE_VALUES [[C]](s64), [[C1]](s64), [[C2]](s64), [[C3]](s64)
75 ; CHECK: $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7 = COPY [[MV]](<4 x s64>)
76 %0:_(s64) = G_CONSTANT i64 0
77 %1:_(s64) = G_CONSTANT i64 1
78 %2:_(s64) = G_CONSTANT i64 2
79 %3:_(s64) = G_CONSTANT i64 3
80 %4:_(<4 x s64>) = G_MERGE_VALUES %0(s64), %1(s64), %2(s64), %3(s64)
81 $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7 = COPY %4(<4 x s64>)
82 ...
83
84 # FIXME: Should be split up
85 # ---
86 # name: test_merge_17_x_i32
87 # body: |
88 # bb.0:
89 # %0:_(s32) = G_CONSTANT i32 0
90 # %1:_(s32) = G_CONSTANT i32 1
91 # %2:_(s32) = G_CONSTANT i32 2
92 # %3:_(s32) = G_CONSTANT i32 3
93
94 # %4:_(s32) = G_CONSTANT i32 4
95 # %5:_(s32) = G_CONSTANT i32 5
96 # %6:_(s32) = G_CONSTANT i32 6
97 # %7:_(s32) = G_CONSTANT i32 7
98
99 # %8:_(s32) = G_CONSTANT i32 8
100 # %9:_(s32) = G_CONSTANT i32 9
101 # %10:_(s32) = G_CONSTANT i32 10
102 # %11:_(s32) = G_CONSTANT i32 11
103
104 # %12:_(s32) = G_CONSTANT i32 12
105 # %13:_(s32) = G_CONSTANT i32 13
106 # %14:_(s32) = G_CONSTANT i32 14
107 # %15:_(s32) = G_CONSTANT i32 15
108
109 # %16:_(s32) = G_CONSTANT i32 16
110
111 # %17:_(<17 x s32>) = G_MERGE_VALUES %0:_(s32), %1:_(s32), %2:_(s32), %3:_(s32), %4:_(s32), %5:_(s32), %6:_(s32), %7:_(s32), %8:_(s32), %9:_(s32), %10:_(s32), %11:_(s32), %12:_(s32), %13:_(s32), %14:_(s32), %15:_(s32), %16:_(s32)
112 # S_ENDPGM implicit %17(<17 x s32>)
113 # ...
0 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
1 # RUN: llc -mtriple=amdgcn-- -O0 -run-pass=legalizer -global-isel -o - %s | FileCheck %s
2
3 ---
4 name: test_unmerge_s64_s32
5 body: |
6 bb.0:
7 ; CHECK-LABEL: name: test_unmerge_s64_s32
8 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 0
9 ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[C]](s64)
10 ; CHECK: $vgpr0 = COPY [[UV]](s32)
11 ; CHECK: $vgpr2 = COPY [[UV1]](s32)
12 %0:_(s64) = G_CONSTANT i64 0
13 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0:_(s64)
14 $vgpr0 = COPY %1(s32)
15 $vgpr2 = COPY %2(s32)
16 ...
17
18 ---
19 name: test_unmerge_v2s32_s32
20 body: |
21 bb.0:
22 liveins: $vgpr0_vgpr1
23 ; CHECK-LABEL: name: test_unmerge_v2s32_s32
24 ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr0_vgpr1
25 ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](<2 x s32>)
26 ; CHECK: $vgpr0 = COPY [[UV]](s32)
27 ; CHECK: $vgpr2 = COPY [[UV1]](s32)
28 %0:_(<2 x s32>) = COPY $vgpr0_vgpr1
29 %1:_(s32), %2:_(s32) = G_UNMERGE_VALUES %0:_(<2 x s32>)
30 $vgpr0 = COPY %1(s32)
31 $vgpr2 = COPY %2(s32)
32 ...