[llvm] 142897d - [Attributor] Only non-exact accesses require a uniform bit-pattern (=0)
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 20 15:35:08 PDT 2022
Author: Johannes Doerfert
Date: 2022-07-20T17:34:50-05:00
New Revision: 142897dd7d587eb7ab6827a626675438527ef75e
URL: https://github.com/llvm/llvm-project/commit/142897dd7d587eb7ab6827a626675438527ef75e
DIFF: https://github.com/llvm/llvm-project/commit/142897dd7d587eb7ab6827a626675438527ef75e.diff
LOG: [Attributor] Only non-exact accesses require a uniform bit-pattern (=0)
If we only have exact accesses we should never require the bit-pattern
to be uniform (in this case 0). Only a non-exact access should force us
to require only 0 values.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/Attributor/value-simplify-gpu.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index aaaadf9cbf428..952c188a582d0 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -378,13 +378,13 @@ static bool getPotentialCopiesOfMemoryValue(
bool NullOnly = true;
bool NullRequired = false;
- auto CheckForNullOnlyAndUndef = [&](Optional<Value *> V) {
+ auto CheckForNullOnlyAndUndef = [&](Optional<Value *> V, bool IsExact) {
if (!V || *V == nullptr)
NullOnly = false;
else if (isa<UndefValue>(*V))
/* No op */;
else if (isa<Constant>(*V) && cast<Constant>(*V)->isNullValue())
- NullRequired = true;
+ NullRequired = !IsExact;
else
NullOnly = false;
};
@@ -395,7 +395,7 @@ static bool getPotentialCopiesOfMemoryValue(
LLVM_DEBUG(dbgs() << "Failed to get initial value: " << *Obj << "\n");
return false;
}
- CheckForNullOnlyAndUndef(InitialValue);
+ CheckForNullOnlyAndUndef(InitialValue, /* IsExact */ true);
NewCopies.push_back(InitialValue);
NewCopyOrigins.push_back(nullptr);
}
@@ -405,7 +405,7 @@ static bool getPotentialCopiesOfMemoryValue(
return true;
if (IsLoad && Acc.isWrittenValueYetUndetermined())
return true;
- CheckForNullOnlyAndUndef(Acc.getContent());
+ CheckForNullOnlyAndUndef(Acc.getContent(), IsExact);
if (OnlyExact && !IsExact && !NullOnly &&
!isa_and_nonnull<UndefValue>(Acc.getWrittenValue())) {
LLVM_DEBUG(dbgs() << "Non exact access " << *Acc.getRemoteInst()
diff --git a/llvm/test/Transforms/Attributor/value-simplify-gpu.ll b/llvm/test/Transforms/Attributor/value-simplify-gpu.ll
index 0ef99fcca3431..fa19fe63622d5 100644
--- a/llvm/test/Transforms/Attributor/value-simplify-gpu.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify-gpu.ll
@@ -288,7 +288,7 @@ define internal void @level2a(i32* %addr) {
; IS__TUNIT____-NEXT: entry:
; IS__TUNIT____-NEXT: [[TMP0:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @ReachableNonKernel to i32*), align 4
; IS__TUNIT____-NEXT: [[TMP1:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @UnreachableNonKernel to i32*), align 4
-; IS__TUNIT____-NEXT: call void @use(i32 [[TMP0]], i32 [[TMP1]], i32 17) #[[ATTR6]]
+; IS__TUNIT____-NEXT: call void @use(i32 noundef [[TMP0]], i32 noundef [[TMP1]], i32 17) #[[ATTR6]]
; IS__TUNIT____-NEXT: ret void
;
; IS__CGSCC____: Function Attrs: nosync nounwind
@@ -298,7 +298,7 @@ define internal void @level2a(i32* %addr) {
; IS__CGSCC____-NEXT: [[TMP0:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @ReachableNonKernel to i32*), align 4
; IS__CGSCC____-NEXT: [[TMP1:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @UnreachableNonKernel to i32*), align 4
; IS__CGSCC____-NEXT: [[QQQQ2:%.*]] = load i32, i32* [[ADDR]], align 4
-; IS__CGSCC____-NEXT: call void @use(i32 [[TMP0]], i32 [[TMP1]], i32 [[QQQQ2]]) #[[ATTR4]]
+; IS__CGSCC____-NEXT: call void @use(i32 noundef [[TMP0]], i32 noundef [[TMP1]], i32 [[QQQQ2]]) #[[ATTR4]]
; IS__CGSCC____-NEXT: ret void
;
entry:
@@ -316,7 +316,7 @@ define internal void @level2b(i32* %addr) {
; IS__TUNIT____-NEXT: entry:
; IS__TUNIT____-NEXT: [[TMP0:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @ReachableNonKernel to i32*), align 4
; IS__TUNIT____-NEXT: [[TMP1:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @UnreachableNonKernel to i32*), align 4
-; IS__TUNIT____-NEXT: call void @use(i32 [[TMP0]], i32 [[TMP1]], i32 17) #[[ATTR6]]
+; IS__TUNIT____-NEXT: call void @use(i32 noundef [[TMP0]], i32 noundef [[TMP1]], i32 17) #[[ATTR6]]
; IS__TUNIT____-NEXT: ret void
;
; IS__CGSCC____: Function Attrs: nosync nounwind
@@ -326,7 +326,7 @@ define internal void @level2b(i32* %addr) {
; IS__CGSCC____-NEXT: [[TMP0:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @ReachableNonKernel to i32*), align 4
; IS__CGSCC____-NEXT: [[TMP1:%.*]] = load i32, i32* addrspacecast (i32 addrspace(3)* @UnreachableNonKernel to i32*), align 4
; IS__CGSCC____-NEXT: [[TMP2:%.*]] = load i32, i32* [[ADDR]], align 4
-; IS__CGSCC____-NEXT: call void @use(i32 [[TMP0]], i32 [[TMP1]], i32 [[TMP2]]) #[[ATTR4]]
+; IS__CGSCC____-NEXT: call void @use(i32 noundef [[TMP0]], i32 noundef [[TMP1]], i32 [[TMP2]]) #[[ATTR4]]
; IS__CGSCC____-NEXT: ret void
;
entry:
More information about the llvm-commits
mailing list