[llvm] 9373a43 - [Attributor] Indicate optimistic fixed point if an instruction already has non-zero address space (#101589)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 19:55:12 PDT 2024
Author: Shilei Tian
Date: 2024-08-01T22:55:09-04:00
New Revision: 9373a43218ba7d55e2ec5c52147ec39daaf8f177
URL: https://github.com/llvm/llvm-project/commit/9373a43218ba7d55e2ec5c52147ec39daaf8f177
DIFF: https://github.com/llvm/llvm-project/commit/9373a43218ba7d55e2ec5c52147ec39daaf8f177.diff
LOG: [Attributor] Indicate optimistic fixed point if an instruction already has non-zero address space (#101589)
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/memory_locations_gpu.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 2816a85743faa..f69054334c739 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -12491,6 +12491,9 @@ struct AAAddressSpaceImpl : public AAAddressSpace {
void initialize(Attributor &A) override {
assert(getAssociatedType()->isPtrOrPtrVectorTy() &&
"Associated value is not a pointer");
+ auto *PtrTy = cast<PointerType>(getAssociatedType());
+ if (PtrTy->getAddressSpace())
+ indicateOptimisticFixpoint();
}
ChangeStatus updateImpl(Attributor &A) override {
diff --git a/llvm/test/Transforms/Attributor/memory_locations_gpu.ll b/llvm/test/Transforms/Attributor/memory_locations_gpu.ll
index 2c7a98a41f86f..c10883b54ad59 100644
--- a/llvm/test/Transforms/Attributor/memory_locations_gpu.ll
+++ b/llvm/test/Transforms/Attributor/memory_locations_gpu.ll
@@ -55,7 +55,8 @@ define i32 @test_const_as_call2() {
; CHECK-LABEL: define {{[^@]+}}@test_const_as_call2
; CHECK-SAME: () #[[ATTR3:[0-9]+]] {
; CHECK-NEXT: [[P2:%.*]] = call ptr @ptr() #[[ATTR4]]
-; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[P2]], align 4
+; CHECK-NEXT: [[C2:%.*]] = addrspacecast ptr [[P2]] to ptr addrspace(4)
+; CHECK-NEXT: [[L2:%.*]] = load i32, ptr addrspace(4) [[C2]], align 4
; CHECK-NEXT: ret i32 [[L2]]
;
%p2 = call ptr @ptr()
@@ -84,7 +85,8 @@ define i32 @test_shared_as_call2() {
; CHECK-LABEL: define {{[^@]+}}@test_shared_as_call2
; CHECK-SAME: () #[[ATTR2]] {
; CHECK-NEXT: [[P2:%.*]] = call ptr @ptr() #[[ATTR4]]
-; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[P2]], align 4
+; CHECK-NEXT: [[C2:%.*]] = addrspacecast ptr [[P2]] to ptr addrspace(3)
+; CHECK-NEXT: [[L2:%.*]] = load i32, ptr addrspace(3) [[C2]], align 4
; CHECK-NEXT: ret i32 [[L2]]
;
%p2 = call ptr @ptr()
More information about the llvm-commits
mailing list