1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=legalizer %s -o - | FileCheck %s
5 name: trunc_s16_merge_s64_s32
9 ; Test that trunc(merge) with trunc-size < merge-source-size creates a trunc
11 ; CHECK-LABEL: name: trunc_s16_merge_s64_s32
12 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
13 ; CHECK-NEXT: $vgpr0 = COPY [[C]](s32)
14 %0:_(s32) = G_CONSTANT i32 0
15 %1:_(s32) = G_CONSTANT i32 1
16 %2:_(s64) = G_MERGE_VALUES %0, %1
17 %3:_(s16) = G_TRUNC %2
18 %4:_(s32) = G_ANYEXT %3
23 name: trunc_s32_merge_s64_s32
27 ; Test that trunc(merge) with trunc-size == merge-source-size is eliminated
28 ; CHECK-LABEL: name: trunc_s32_merge_s64_s32
29 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
30 ; CHECK-NEXT: $vgpr0 = COPY [[C]](s32)
31 %0:_(s32) = G_CONSTANT i32 0
32 %1:_(s32) = G_CONSTANT i32 1
33 %2:_(s64) = G_MERGE_VALUES %0, %1
34 %3:_(s32) = G_TRUNC %2
39 name: trunc_s64_merge_s128_s32
43 ; Test that trunc(merge) with trunc-size > merge-source-size combines to a
45 ; CHECK-LABEL: name: trunc_s64_merge_s128_s32
46 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
47 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
48 ; CHECK-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[C]](s32), [[C1]](s32)
49 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[MV]](s64)
50 %0:_(s32) = G_CONSTANT i32 0
51 %1:_(s32) = G_CONSTANT i32 1
52 %2:_(s128) = G_MERGE_VALUES %0, %1, %0, %1
53 %3:_(s64) = G_TRUNC %2
54 $vgpr0_vgpr1 = COPY %3
58 name: trunc_s32_merge_s128_p0
62 ; Test that trunc(merge) with a non-scalar merge source is not combined
63 ; CHECK-LABEL: name: trunc_s32_merge_s128_p0
64 ; CHECK: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
65 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(p0) = G_CONSTANT i64 1
66 ; CHECK-NEXT: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[C]](p0), [[C1]](p0)
67 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[MV]](s128)
68 ; CHECK-NEXT: $vgpr0 = COPY [[TRUNC]](s32)
69 %0:_(p0) = G_CONSTANT i64 0
70 %1:_(p0) = G_CONSTANT i64 1
71 %2:_(s128) = G_MERGE_VALUES %0, %1
72 %3:_(s32) = G_TRUNC %2
77 name: trunc_s64_merge_s128_p0
81 ; Test that trunc(merge) with a non-scalar merge source is not combined
82 ; CHECK-LABEL: name: trunc_s64_merge_s128_p0
83 ; CHECK: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
84 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(p0) = G_CONSTANT i64 1
85 ; CHECK-NEXT: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[C]](p0), [[C1]](p0)
86 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[MV]](s128)
87 ; CHECK-NEXT: $vgpr0_vgpr1 = COPY [[TRUNC]](s64)
88 %0:_(p0) = G_CONSTANT i64 0
89 %1:_(p0) = G_CONSTANT i64 1
90 %2:_(s128) = G_MERGE_VALUES %0, %1
91 %3:_(s64) = G_TRUNC %2
92 $vgpr0_vgpr1 = COPY %3
96 name: trunc_s128_merge_s192_p0
100 ; Test that trunc(merge) with a non-scalar merge source is not combined
101 ; CHECK-LABEL: name: trunc_s128_merge_s192_p0
102 ; CHECK: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0
103 ; CHECK-NEXT: [[C1:%[0-9]+]]:_(p0) = G_CONSTANT i64 1
104 ; CHECK-NEXT: [[MV:%[0-9]+]]:_(s192) = G_MERGE_VALUES [[C]](p0), [[C1]](p0), [[C]](p0)
105 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s128) = G_TRUNC [[MV]](s192)
106 ; CHECK-NEXT: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[TRUNC]](s128)
107 %0:_(p0) = G_CONSTANT i64 0
108 %1:_(p0) = G_CONSTANT i64 1
109 %2:_(s192) = G_MERGE_VALUES %0, %1, %0
110 %3:_(s128) = G_TRUNC %2
111 $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %3
115 name: trunc_s68_merge_s128_s32
119 ; Test that trunc(merge) with trunc-size > merge-source-size and
120 ; trunc-size % merge-source-size != 0 can be combined after the G_TRUNCs
121 ; have been combined.
122 ; CHECK-LABEL: name: trunc_s68_merge_s128_s32
123 ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
124 ; CHECK-NEXT: $vgpr0 = COPY [[C]](s32)
125 %0:_(s32) = G_CONSTANT i32 0
126 %1:_(s32) = G_CONSTANT i32 1
127 %2:_(s128) = G_MERGE_VALUES %0, %1, %0, %1
128 %3:_(s68) = G_TRUNC %2
129 %4:_(s32) = G_TRUNC %3
138 ; Test that trunc(trunc) is combined to a single trunc
139 ; CHECK-LABEL: name: trunc_trunc
140 ; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
141 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[DEF]](s64)
142 ; CHECK-NEXT: $vgpr0 = COPY [[TRUNC]](s32)
143 %0:_(s64) = G_IMPLICIT_DEF
144 %1:_(s48) = G_TRUNC %0
145 %2:_(s32) = G_TRUNC %1
154 ; Test that trunc(sext) is replaced with sext source.
155 ; CHECK-LABEL: name: trunc_sext
156 ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
157 ; CHECK-NEXT: $vgpr0 = COPY [[DEF]](s32)
158 %0:_(s32) = G_IMPLICIT_DEF
159 %1:_(s64) = G_SEXT %0
160 %2:_(s32) = G_TRUNC %1
169 ; Test that trunc(zext) is replaced with zext source.
170 ; CHECK-LABEL: name: trunc_zext
171 ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
172 ; CHECK-NEXT: $vgpr0 = COPY [[DEF]](s32)
173 %0:_(s32) = G_IMPLICIT_DEF
174 %1:_(s64) = G_ZEXT %0
175 %2:_(s32) = G_TRUNC %1
184 ; Test that trunc(anyext) is replaced with anyext source.
185 ; CHECK-LABEL: name: trunc_anyext
186 ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
187 ; CHECK-NEXT: $vgpr0 = COPY [[DEF]](s32)
188 %0:_(s32) = G_IMPLICIT_DEF
189 %1:_(s64) = G_ANYEXT %0
190 %2:_(s32) = G_TRUNC %1
199 ; Test that trunc(sext (trunc (...))) is replaced with source.
200 ; CHECK-LABEL: name: trunc_ext
201 ; CHECK: [[DEF:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
202 ; CHECK-NEXT: $vgpr0 = COPY [[DEF]](s32)
203 %0:_(s32) = G_IMPLICIT_DEF
204 %1:_(s64) = G_SEXT %0
205 %2:_(s32) = G_TRUNC %1
206 %3:_(s128) = G_ZEXT %2
207 %4:_(s64) = G_TRUNC %3
208 %5:_(s32) = G_TRUNC %4