Skip to content

Commit 3bf33ec

Browse files
authored
[GlobalISel] Fold bitcast(undef) to undef. (#111491)
As with other operations such as trunc and fp converts, it should be valid to convert bitcast(undef) to undef.
1 parent ada6372 commit 3bf33ec

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

llvm/include/llvm/Target/GlobalISel/Combine.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def unary_undef_to_zero: GICombineRule<
420420
// replaced with undef.
421421
def propagate_undef_any_op: GICombineRule<
422422
(defs root:$root),
423-
(match (wip_match_opcode G_ADD, G_FPTOSI, G_FPTOUI, G_SUB, G_XOR, G_TRUNC):$root,
423+
(match (wip_match_opcode G_ADD, G_FPTOSI, G_FPTOUI, G_SUB, G_XOR, G_TRUNC, G_BITCAST):$root,
424424
[{ return Helper.matchAnyExplicitUseIsUndef(*${root}); }]),
425425
(apply [{ Helper.replaceInstWithUndef(*${root}); }])>;
426426

llvm/test/CodeGen/AArch64/concat-vector.ll

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -189,28 +189,17 @@ define <8 x i16> @concat_v8s16_v2s16(ptr %ptr) {
189189
; CHECK-GI-NEXT: xtn v0.4h, v0.4s
190190
; CHECK-GI-NEXT: fmov w8, s0
191191
; CHECK-GI-NEXT: mov v0.s[0], w8
192-
; CHECK-GI-NEXT: mov v0.s[1], w8
193-
; CHECK-GI-NEXT: mov v0.s[2], w8
194-
; CHECK-GI-NEXT: mov v0.s[3], w8
195192
; CHECK-GI-NEXT: ret
196193
%a = load <2 x i16>, ptr %ptr
197194
%b = shufflevector <2 x i16> %a, <2 x i16> %a, <8 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
198195
ret <8 x i16> %b
199196
}
200197

201198
define <16 x i8> @concat_v16s8_v4s8(ptr %ptr) {
202-
; CHECK-SD-LABEL: concat_v16s8_v4s8:
203-
; CHECK-SD: // %bb.0:
204-
; CHECK-SD-NEXT: ldr s0, [x0]
205-
; CHECK-SD-NEXT: ret
206-
;
207-
; CHECK-GI-LABEL: concat_v16s8_v4s8:
208-
; CHECK-GI: // %bb.0:
209-
; CHECK-GI-NEXT: ldr s0, [x0]
210-
; CHECK-GI-NEXT: mov v0.s[1], w8
211-
; CHECK-GI-NEXT: mov v0.s[2], w8
212-
; CHECK-GI-NEXT: mov v0.s[3], w8
213-
; CHECK-GI-NEXT: ret
199+
; CHECK-LABEL: concat_v16s8_v4s8:
200+
; CHECK: // %bb.0:
201+
; CHECK-NEXT: ldr s0, [x0]
202+
; CHECK-NEXT: ret
214203
%a = load <4 x i8>, ptr %ptr
215204
%b = shufflevector <4 x i8> %a, <4 x i8> %a, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
216205
ret <16 x i8> %b

0 commit comments

Comments
 (0)