-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[X86][GISel] Add missing legalization for G_IMPLICIT_DEF #161699
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
Changes from 2 commits
81e18b2
9decd8a
0024770
381281a
614e875
5d2aba5
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 |
---|---|---|
|
@@ -91,7 +91,27 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI, | |
// s128 = EXTEND (G_IMPLICIT_DEF s32/s64) -> s128 = G_IMPLICIT_DEF | ||
getActionDefinitionsBuilder(G_IMPLICIT_DEF) | ||
.legalFor({p0, s1, s8, s16, s32, s64}) | ||
.legalFor(Is64Bit, {s128}); | ||
.legalFor(Is64Bit, {s128}) | ||
.legalFor(HasSSE2, {v16s8, v8s16, v4s32, v2s64}) | ||
.legalFor(HasAVX, {v8s32, v4s64}) | ||
.legalFor(HasAVX2, {v32s8, v16s16, v8s32, v4s64}) | ||
|
||
.legalFor(HasAVX512, {v16s32, v8s64}) | ||
.legalFor(HasBWI, {v64s8, v32s16}) | ||
|
||
.widenScalarOrEltToNextPow2(0, /*Min=*/8) | ||
.clampScalarOrElt(0, s8, sMaxScalar) | ||
.moreElementsToNextPow2(0) | ||
.clampMinNumElements(0, s8, 16) | ||
.clampMinNumElements(0, s16, 8) | ||
.clampMinNumElements(0, s32, 4) | ||
.clampMinNumElements(0, s64, 2) | ||
.clampMaxNumElements(0, s8, HasBWI ? 64 : (HasAVX2 ? 32 : 16)) | ||
.clampMaxNumElements(0, s16, HasBWI ? 32 : (HasAVX2 ? 16 : 8)) | ||
.clampMaxNumElements(0, s32, HasAVX512 ? 16 : (HasAVX2 ? 8 : 4)) | ||
.clampMaxNumElements(0, s64, HasAVX512 ? 8 : (HasAVX2 ? 4 : 2)) | ||
.clampMaxNumElements(0, p0, | ||
Is64Bit ? s64MaxVector.getNumElements() | ||
: s32MaxVector.getNumElements()) | ||
.scalarizeIf(scalarOrEltWiderThan(0, 64), 0); | ||
|
||
getActionDefinitionsBuilder(G_CONSTANT) | ||
.legalFor({p0, s8, s16, s32}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# RUN: llc -mtriple=x86_64-linux-gnu -mattr=avx2 -run-pass=legalizer -global-isel-abort=2 -pass-remarks-missed='gisel*' %s -o - | FileCheck %s --check-prefixes=CHECK,AVX2 | ||
# RUN: llc -mtriple=x86_64-linux-gnu -mattr=sse2 -run-pass=legalizer -global-isel-abort=2 -pass-remarks-missed='gisel*' %s -o - | FileCheck %s --check-prefixes=CHECK,SSE2 | ||
# RUN: llc -mtriple=x86_64-linux-gnu -mattr=avx512f -run-pass=legalizer -global-isel-abort=2 -pass-remarks-missed='gisel*' %s -o - | FileCheck %s --check-prefixes=CHECK,AVX512F | ||
|
||
|
||
--- | ||
name: test_basic_g_implicit_def_v8i64 | ||
body: | | ||
bb.0: | ||
; CHECK-LABEL: name: test_basic_g_implicit_def_v8i64 | ||
; AVX512F: {{%[0-9]+}}:_(<8 x s64>) = G_IMPLICIT_DEF | ||
; AVX2: [[DEF_AVX2:%[0-9]+]]:_(<4 x s64>) = G_IMPLICIT_DEF | ||
; AVX2-NEXT: {{%[0-9]+}}:_(<8 x s64>) = G_CONCAT_VECTORS [[DEF_AVX2]](<4 x s64>), [[DEF_AVX2]](<4 x s64>) | ||
; SSE2: [[DEF_SSE2:%[0-9]+]]:_(<2 x s64>) = G_IMPLICIT_DEF | ||
; SSE2-NEXT: {{%[0-9]+}}:_(<8 x s64>) = G_CONCAT_VECTORS [[DEF_SSE2]](<2 x s64>), [[DEF_SSE2]](<2 x s64>), [[DEF_SSE2]](<2 x s64>), [[DEF_SSE2]](<2 x s64>) | ||
%0:_(<8 x s64>) = G_IMPLICIT_DEF | ||
RET 0, implicit %0 | ||
... | ||
|
||
--- | ||
name: test_g_implicit_def_cample_size | ||
body: | | ||
bb.1: | ||
; CHECK-LABEL: name: test_g_implicit_def_cample_size | ||
; AVX512: {{%[0-9]+}}:_(<8 x s64>) = G_IMPLICIT_DEF | ||
; AVX2: {{%[0-9]+}}:_(<4 x s64>) = G_IMPLICIT_DEF | ||
; SSE2: {{%[0-9]+}}:_(<2 x s64>) = G_IMPLICIT_DEF | ||
%0:_(<5 x s63>) = G_IMPLICIT_DEF | ||
RET 0, implicit %0 | ||
... | ||
|
||
|
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.
G_PHI, G_IMPLICIT_DEF, and G_FREEZE (and a few others) should have identical rule sets
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.
Do you mean grouping them under the same
ActionDefinitionsBuilder
so they share an identical rule set?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.
Yes. We probably should enforce this somehow. We have an implicit notion of legal types, which we would be better off if we formalized and had the machine verifier enforce. It's certainly weaker than the DAG case, but we do need to guarantee a set of properties to ensure the legalizer can complete
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.
For now I will fuse them in the legalizer, and I’ll look to see how we can enforce this in the machine verifier.