-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang] Allow vector and matrix type attributes for sub-byte _BitInt #140253
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -571,6 +571,41 @@ void VectorTest(uint16_t4 first, uint16_t4 second) { | |
| // CHECK: %[[ADD:.+]] = add <3 x i16> %[[Shuffle]], %[[Shuffle1]] | ||
| } | ||
|
|
||
| typedef unsigned _BitInt(4) uint4_t4 __attribute__((ext_vector_type(4))); | ||
| void VectorTest(uint4_t4 first, uint4_t4 second) { | ||
| // LIN64: define{{.*}} void @_Z10VectorTestDv4_DU4_S0_(i32 %{{.+}}, i32 %{{.+}}) | ||
| // LIN32: define{{.*}} void @_Z10VectorTestDv4_DU4_S0_(<4 x i4> %{{.+}}, <4 x i4> %{{.+}}) | ||
| // WIN64: define dso_local void @"?VectorTest@@YAXT?$__vector@U?$_UBitInt@$03@__clang@@$03@__clang@@0@Z"(<4 x i4> %{{.+}}, <4 x i4> %{{.+}}) | ||
| // WIN32: define dso_local void @"?VectorTest@@YAXT?$__vector@U?$_UBitInt@$03@__clang@@$03@__clang@@0@Z"(<4 x i4> inreg %{{.+}}, <4 x i4> inreg %{{.+}}) | ||
| first.xzw + second.zwx; | ||
| // CHECK: %[[Shuffle:.+]] = shufflevector <4 x i4> %{{.+}}, <4 x i4> poison, <3 x i32> <i32 0, i32 2, i32 3> | ||
| // CHECK: %[[Shuffle1:.+]] = shufflevector <4 x i4> %{{.+}}, <4 x i4> poison, <3 x i32> <i32 2, i32 3, i32 0> | ||
| // CHECK: %[[ADD:.+]] = add <3 x i4> %[[Shuffle]], %[[Shuffle1]] | ||
| } | ||
|
|
||
| typedef unsigned _BitInt(2) uint2_t2 __attribute__((ext_vector_type(2))); | ||
| uint2_t2 TestBitIntVector2x2Alloca(uint2_t2 v1, uint2_t2 v2) { | ||
| // LIN64: define dso_local i16 @_Z25TestBitIntVector2x2AllocaDv2_DU2_S0_(i16 %[[V1Coerce:.+]], i16 %[[V2Coerce:.+]]) | ||
| // LIN64: %[[RetVal:.+]] = alloca <2 x i2>, align 2 | ||
|
Contributor
Author
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. TBH I was surprised to see alloca 2xi2 and not alloca i8 here
Member
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. I would have also expected |
||
| // LIN64: %[[V1Addr:.+]] = alloca <2 x i2>, align 2 | ||
| // LIN64: %[[V2Addr:.+]] = alloca <2 x i2>, align 2 | ||
| // LIN64: %[[RetValCoerce:.+]] = alloca i16, align 2 | ||
| // LIN64: call void @llvm.memcpy.p0.p0.i64(ptr align 2 %[[RetValCoerce]], ptr align 2 %[[RetVal]], i64 1, i1 false) | ||
| // LIN64: %[[Ret:.+]] = load i16, ptr %[[RetValCoerce]], align 2 | ||
| // LIN64: ret i16 %[[Ret]] | ||
|
|
||
| // LIN32: define dso_local <2 x i2> @_Z25TestBitIntVector2x2AllocaDv2_DU2_S0_(<2 x i2> %{{.+}}, <2 x i2> %{{.+}}) | ||
| // LIN32: %[[V1Addr:.+]] = alloca <2 x i2>, align 2 | ||
| // LIN32: %[[V2Addr:.+]] = alloca <2 x i2>, align 2 | ||
| // LIN32: ret <2 x i2> %[[Ret:.+]] | ||
|
|
||
| // WIN: define dso_local <2 x i2> @"?TestBitIntVector2x2Alloca@@YAT?$__vector@U?$_UBitInt@$01@__clang@@$01@__clang@@T12@0@Z"(<2 x i2>{{.*}}, <2 x i2>{{.*}}) | ||
| // WIN: %[[V1:.+]] = alloca <2 x i2>, align 2 | ||
| // WIN: %[[V2:.+]] = alloca <2 x i2>, align 2 | ||
| // WIN: ret <2 x i2> %[[Ret:.+]] | ||
| return v1 + v2; | ||
| } | ||
|
|
||
| // Ensure that these types don't alias the normal int types. | ||
| void TBAATest(_BitInt(sizeof(int) * 8) ExtInt, | ||
| unsigned _BitInt(sizeof(int) * 8) ExtUInt, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s | ||
|
|
||
| define dso_local <2 x i2> @foo(<2 x i2> %v1, <2 x i2> %v2) { | ||
| ; CHECK-LABEL: foo: | ||
| ; CHECK: # %bb.0: # %entry | ||
| ; CHECK-NEXT: movq %xmm1, %rax | ||
| ; CHECK-NEXT: andb $3, %al | ||
| ; CHECK-NEXT: pshufd {{.*#+}} xmm2 = xmm1[2,3,2,3] | ||
| ; CHECK-NEXT: movq %xmm2, %rcx | ||
| ; CHECK-NEXT: shlb $2, %cl | ||
| ; CHECK-NEXT: orb %al, %cl | ||
| ; CHECK-NEXT: andb $15, %cl | ||
| ; CHECK-NEXT: movb %cl, -{{[0-9]+}}(%rsp) | ||
| ; CHECK-NEXT: movq %xmm0, %rax | ||
| ; CHECK-NEXT: andb $3, %al | ||
| ; CHECK-NEXT: pshufd {{.*#+}} xmm2 = xmm0[2,3,2,3] | ||
| ; CHECK-NEXT: movq %xmm2, %rcx | ||
| ; CHECK-NEXT: shlb $2, %cl | ||
| ; CHECK-NEXT: orb %al, %cl | ||
| ; CHECK-NEXT: andb $15, %cl | ||
| ; CHECK-NEXT: movb %cl, -{{[0-9]+}}(%rsp) | ||
| ; CHECK-NEXT: paddq %xmm1, %xmm0 | ||
| ; CHECK-NEXT: retq | ||
| entry: | ||
| %v2.addr = alloca <2 x i2>, align 2 | ||
| %v1.addr = alloca <2 x i2>, align 2 | ||
| store <2 x i2> %v2, ptr %v2.addr, align 2 | ||
| store <2 x i2> %v1, ptr %v1.addr, align 2 | ||
| %0 = load <2 x i2>, ptr %v1.addr, align 2 | ||
| %1 = load <2 x i2>, ptr %v2.addr, align 2 | ||
| %add = add <2 x i2> %0, %1 | ||
| ret <2 x i2> %add | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
name suggests, that I had also TestBitIntVector3/4/8x2Alloca tests, but they were not interesting (for me, as I've been expecting to see alloca i8 -> i16 etc there, but got alloca vector), just 3 element test case brough some expected shuffles, but it's tested elsewhere many times.