-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[GlobalISel] Turn shuffle a, b, mask -> shuffle undef, b, mask iff mask does not reference a #115377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GlobalISel] Turn shuffle a, b, mask -> shuffle undef, b, mask iff mask does not reference a #115377
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner %s -o - | FileCheck %s | ||
|
||
--- | ||
name: shuffle_vector_unused_lhs | ||
tracksRegLiveness: true | ||
body: | | ||
bb.1: | ||
liveins: $d0, $d1 | ||
|
||
; CHECK-LABEL: name: shuffle_vector_unused_lhs | ||
; CHECK: liveins: $d0, $d1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d1 | ||
; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF | ||
; CHECK-NEXT: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[DEF]], shufflemask(1, 0, 1, 0) | ||
; CHECK-NEXT: RET_ReallyLR implicit [[SHUF]](<4 x s32>) | ||
%0:_(<2 x s32>) = COPY $d0 | ||
%1:_(<2 x s32>) = COPY $d1 | ||
%2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0(<2 x s32>), %1(<2 x s32>), shufflemask(3, 2, 3, 2) | ||
RET_ReallyLR implicit %2 | ||
... | ||
|
||
--- | ||
name: shuffle_vector_unused_rhs | ||
tracksRegLiveness: true | ||
body: | | ||
bb.1: | ||
liveins: $d0, $d1 | ||
|
||
; CHECK-LABEL: name: shuffle_vector_unused_rhs | ||
; CHECK: liveins: $d0, $d1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0 | ||
; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF | ||
; CHECK-NEXT: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[DEF]], shufflemask(0, 0, 1, 1) | ||
; CHECK-NEXT: RET_ReallyLR implicit [[SHUF]](<4 x s32>) | ||
%0:_(<2 x s32>) = COPY $d0 | ||
%1:_(<2 x s32>) = COPY $d1 | ||
%2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0, %1, shufflemask(0,0,1,1) | ||
RET_ReallyLR implicit %2 | ||
... | ||
|
||
--- | ||
name: shuffle_vector_both_used | ||
tracksRegLiveness: true | ||
body: | | ||
bb.1: | ||
liveins: $d0, $d1 | ||
|
||
; CHECK-LABEL: name: shuffle_vector_both_used | ||
; CHECK: liveins: $d0, $d1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $d1 | ||
; CHECK-NEXT: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[COPY1]], shufflemask(0, 2, 1, 3) | ||
; CHECK-NEXT: RET_ReallyLR implicit [[SHUF]](<4 x s32>) | ||
%0:_(<2 x s32>) = COPY $d0 | ||
%1:_(<2 x s32>) = COPY $d1 | ||
%2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0, %1, shufflemask(0,2,1,3) | ||
RET_ReallyLR implicit %2 | ||
... | ||
|
||
--- | ||
name: shuffle_vector_undef_elems | ||
tracksRegLiveness: true | ||
body: | | ||
bb.1: | ||
liveins: $d0, $d1 | ||
|
||
; CHECK-LABEL: name: shuffle_vector_undef_elems | ||
; CHECK: liveins: $d0, $d1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(<2 x s32>) = COPY $d0 | ||
; CHECK-NEXT: [[DEF:%[0-9]+]]:_(<2 x s32>) = G_IMPLICIT_DEF | ||
; CHECK-NEXT: [[SHUF:%[0-9]+]]:_(<4 x s32>) = G_SHUFFLE_VECTOR [[COPY]](<2 x s32>), [[DEF]], shufflemask(undef, 0, 1, undef) | ||
; CHECK-NEXT: RET_ReallyLR implicit [[SHUF]](<4 x s32>) | ||
%0:_(<2 x s32>) = COPY $d0 | ||
%1:_(<2 x s32>) = COPY $d1 | ||
%2:_(<4 x s32>) = G_SHUFFLE_VECTOR %0, %1, shufflemask(-1,0,1,-1) | ||
RET_ReallyLR implicit %2 | ||
... | ||
|
||
--- | ||
name: shuffle_vector_scalar | ||
tracksRegLiveness: true | ||
body: | | ||
bb.1: | ||
liveins: $x0, $x1 | ||
|
||
; CHECK-LABEL: name: shuffle_vector_scalar | ||
; CHECK: liveins: $x0, $x1 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0 | ||
; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<4 x s64>) = G_BUILD_VECTOR [[COPY]](s64), [[COPY]](s64), [[COPY]](s64), [[COPY]](s64) | ||
; CHECK-NEXT: RET_ReallyLR implicit [[BUILD_VECTOR]](<4 x s64>) | ||
%0:_(s64) = COPY $x0 | ||
%1:_(s64) = COPY $x1 | ||
%2:_(<4 x s64>) = G_SHUFFLE_VECTOR %0, %1, shufflemask(0, 0, 0, 0) | ||
RET_ReallyLR implicit %2 | ||
... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,50 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s --check-prefixes=CHECK,CHECK-SD | ||
; RUN: llc < %s -mtriple=arm64-eabi -global-isel=1 -aarch64-neon-syntax=apple | FileCheck %s --check-prefixes=CHECK,CHECK-GI | ||
; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s --check-prefix=CHECK-SD | ||
; RUN: llc < %s -mtriple=arm64-eabi -global-isel=1 -aarch64-neon-syntax=apple | FileCheck %s --check-prefix=CHECK-GI | ||
|
||
; Extract of an upper half of a vector is an "ext.16b v0, v0, v0, #8" insn. | ||
|
||
define <8 x i8> @v8i8(<16 x i8> %a) nounwind { | ||
; CHECK-LABEL: v8i8: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-NEXT: ret | ||
; CHECK-SD-LABEL: v8i8: | ||
; CHECK-SD: // %bb.0: | ||
; CHECK-SD-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-SD-NEXT: ret | ||
; | ||
; CHECK-GI-LABEL: v8i8: | ||
; CHECK-GI: // %bb.0: | ||
; CHECK-GI-NEXT: mov d0, v0[1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After rebasing this commit now also modifies this test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it looks OK, they should both be about the same. I would keep the prefixes though, to keep them in sync with how we run the other tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no common CHECK lines left, so FileCheck was complaining:
|
||
; CHECK-GI-NEXT: ret | ||
%ret = shufflevector <16 x i8> %a, <16 x i8> %a, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> | ||
ret <8 x i8> %ret | ||
} | ||
|
||
define <4 x i16> @v4i16(<8 x i16> %a) nounwind { | ||
; CHECK-LABEL: v4i16: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-NEXT: ret | ||
; CHECK-SD-LABEL: v4i16: | ||
; CHECK-SD: // %bb.0: | ||
; CHECK-SD-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-SD-NEXT: ret | ||
; | ||
; CHECK-GI-LABEL: v4i16: | ||
; CHECK-GI: // %bb.0: | ||
; CHECK-GI-NEXT: mov d0, v0[1] | ||
; CHECK-GI-NEXT: ret | ||
%ret = shufflevector <8 x i16> %a, <8 x i16> %a, <4 x i32> <i32 4, i32 5, i32 6, i32 7> | ||
ret <4 x i16> %ret | ||
} | ||
|
||
define <2 x i32> @v2i32(<4 x i32> %a) nounwind { | ||
; CHECK-LABEL: v2i32: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-NEXT: ret | ||
; CHECK-SD-LABEL: v2i32: | ||
; CHECK-SD: // %bb.0: | ||
; CHECK-SD-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-SD-NEXT: ret | ||
; | ||
; CHECK-GI-LABEL: v2i32: | ||
; CHECK-GI: // %bb.0: | ||
; CHECK-GI-NEXT: mov d0, v0[1] | ||
; CHECK-GI-NEXT: ret | ||
%ret = shufflevector <4 x i32> %a, <4 x i32> %a, <2 x i32> <i32 2, i32 3> | ||
ret <2 x i32> %ret | ||
} | ||
|
@@ -65,11 +80,16 @@ define <1 x ptr> @v1p0(<2 x ptr> %a) nounwind { | |
} | ||
|
||
define <2 x float> @v2f32(<4 x float> %a) nounwind { | ||
; CHECK-LABEL: v2f32: | ||
; CHECK: // %bb.0: | ||
; CHECK-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-NEXT: ret | ||
; CHECK-SD-LABEL: v2f32: | ||
; CHECK-SD: // %bb.0: | ||
; CHECK-SD-NEXT: ext.16b v0, v0, v0, #8 | ||
; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0 | ||
; CHECK-SD-NEXT: ret | ||
; | ||
; CHECK-GI-LABEL: v2f32: | ||
; CHECK-GI: // %bb.0: | ||
; CHECK-GI-NEXT: mov d0, v0[1] | ||
; CHECK-GI-NEXT: ret | ||
%ret = shufflevector <4 x float> %a, <4 x float> %a, <2 x i32> <i32 2, i32 3> | ||
ret <2 x float> %ret | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the discussion on this PR, you can remove this again since it should be impossible for G_IMPLICIT_DEF of that type to be illegal.