-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[AMDGPU] Apply alignment attr for make.buffer.rsrc #166914
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 all commits
4d3d6e4
505426b
4245ca5
07415ef
841bbe5
7be66a0
5efe07b
9d04645
5e3479c
0da0b42
533ca2f
7f29a7a
ff6c8d7
a5a8b66
989017e
a8792cc
19d5915
015e701
4aa04b1
09d4a9b
5af566a
677876b
96f5892
68c8e42
b4bdc67
d17d04c
7431be9
d72fa3a
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 |
|---|---|---|
|
|
@@ -5220,6 +5220,13 @@ static unsigned getKnownAlignForUse(Attributor &A, AAAlign &QueryingAA, | |
| return AlignAA->getKnownAlign().value(); | ||
| break; | ||
| } | ||
| case Intrinsic::amdgcn_make_buffer_rsrc: { | ||
| const auto *AlignAA = A.getAAFor<AAAlign>( | ||
| QueryingAA, IRPosition::value(*II), DepClassTy::NONE); | ||
| if (AlignAA) | ||
| return AlignAA->getKnownAlign().value(); | ||
| break; | ||
| } | ||
| default: | ||
| break; | ||
| } | ||
|
|
@@ -5543,7 +5550,7 @@ struct AAAlignCallSiteReturned final | |
| const auto *AlignAA = | ||
| A.getAAFor<AAAlign>(*this, IRPosition::value(*(II->getOperand(0))), | ||
| DepClassTy::REQUIRED); | ||
| if (AlignAA && AlignAA->isValidState()) { | ||
| if (AlignAA) { | ||
|
Contributor
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. not sure about this change
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. Hi @shiltian , if I'm not wrong the AAAlign would be invalid if assumed alignment is 1: /// See AbstractState::isValidState()
/// NOTE: For now we simply pretend that the worst possible state is invalid.
bool isValidState() const override { return Assumed != getWorstState(); }In this case, if mask is not valid, then assumed alignment of ptrmask should also be 1... |
||
| Alignment = std::max(AlignAA->getAssumedAlign(), Alignment); | ||
| Valid = true; | ||
| } | ||
|
|
@@ -5554,6 +5561,18 @@ struct AAAlignCallSiteReturned final | |
| std::min(this->getAssumedAlign(), Alignment).value()); | ||
| break; | ||
| } | ||
| // FIXME: Should introduce target specific sub-attributes and letting | ||
| // getAAfor<AAAlign> lead to create sub-attribute to handle target | ||
| // specific intrinsics. | ||
| case Intrinsic::amdgcn_make_buffer_rsrc: { | ||
| const auto *AlignAA = | ||
| A.getAAFor<AAAlign>(*this, IRPosition::value(*(II->getOperand(0))), | ||
| DepClassTy::REQUIRED); | ||
| if (AlignAA) | ||
| return clampStateAndIndicateChange<StateType>( | ||
| this->getState(), AlignAA->getAssumedAlign().value()); | ||
| break; | ||
| } | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 | ||
| ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-attributor %s -o - | FileCheck %s | ||
|
|
||
| define float @align_back_prop(ptr addrspace(1) align 4 %x) { | ||
| ; CHECK-LABEL: define float @align_back_prop( | ||
| ; CHECK-SAME: ptr addrspace(1) align 8 [[X:%.*]]) #[[ATTR0:[0-9]+]] { | ||
| ; CHECK-NEXT: [[FAT_PTR:%.*]] = call align 8 ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p1(ptr addrspace(1) [[X]], i16 0, i64 256, i32 0) | ||
| ; CHECK-NEXT: [[Y:%.*]] = load float, ptr addrspace(7) [[FAT_PTR]], align 8 | ||
| ; CHECK-NEXT: ret float [[Y]] | ||
| ; | ||
| %fat.ptr = call ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p1(ptr addrspace(1) %x, i16 0, i64 256, i32 0) | ||
| %y = load float, ptr addrspace(7) %fat.ptr, align 8 | ||
| ret float %y | ||
| } | ||
|
|
||
| define float @align_foward_prop(ptr addrspace(1) align 8 %x) { | ||
| ; CHECK-LABEL: define float @align_foward_prop( | ||
| ; CHECK-SAME: ptr addrspace(1) align 8 [[X:%.*]]) #[[ATTR0]] { | ||
| ; CHECK-NEXT: [[FAT_PTR:%.*]] = call align 8 ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p1(ptr addrspace(1) [[X]], i16 0, i64 256, i32 0) | ||
| ; CHECK-NEXT: [[Y:%.*]] = load float, ptr addrspace(7) [[FAT_PTR]], align 8 | ||
| ; CHECK-NEXT: ret float [[Y]] | ||
| ; | ||
| %fat.ptr = call ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p1(ptr addrspace(1) %x, i16 0, i64 256, i32 0) | ||
| %y = load float, ptr addrspace(7) %fat.ptr, align 4 | ||
| ret float %y | ||
| } | ||
|
|
||
| define float @align_mix_prop(ptr addrspace(1) align 4 %x) { | ||
| ; CHECK-LABEL: define float @align_mix_prop( | ||
| ; CHECK-SAME: ptr addrspace(1) align 8 [[X:%.*]]) #[[ATTR0]] { | ||
| ; CHECK-NEXT: [[FAT_PTR:%.*]] = call align 8 ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p1(ptr addrspace(1) [[X]], i16 0, i64 256, i32 0) | ||
| ; CHECK-NEXT: [[Y:%.*]] = load float, ptr addrspace(7) [[FAT_PTR]], align 8 | ||
| ; CHECK-NEXT: [[Z:%.*]] = load float, ptr addrspace(1) [[X]], align 8 | ||
| ; CHECK-NEXT: ret float [[Z]] | ||
| ; | ||
| %fat.ptr = call ptr addrspace(7) @llvm.amdgcn.make.buffer.rsrc.p7.p1(ptr addrspace(1) %x, i16 0, i64 256, i32 0) | ||
| %y = load float, ptr addrspace(7) %fat.ptr, align 2 | ||
| %z = load float, ptr addrspace(1) %x, align 8 | ||
| ret float %z | ||
| } |
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.
add a comment here regarding the handling of target specific handling and some future direction that we might take.