[llvm] 70b75f6 - [OpenMP] Try to simplify all loads in device code
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 26 23:45:50 PDT 2021
Author: Johannes Doerfert
Date: 2021-07-27T01:44:15-05:00
New Revision: 70b75f62fc617f1fa7e4859571a99137297146c6
URL: https://github.com/llvm/llvm-project/commit/70b75f62fc617f1fa7e4859571a99137297146c6
DIFF: https://github.com/llvm/llvm-project/commit/70b75f62fc617f1fa7e4859571a99137297146c6.diff
LOG: [OpenMP] Try to simplify all loads in device code
Eliminating loads/stores in the device code is worth the extra effort,
especially for the new device runtime.
At the same time we do not compute AAExecutionDomain for non-device code
anymore, there is no point.
Differential Revision: https://reviews.llvm.org/D106845
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index c9a242803d79..25f3f2ccfb1b 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1544,6 +1544,13 @@ struct Attributor {
UsedAssumedInformation);
}
+ /// If \p V is assumed simplified, return it, if it is unclear yet,
+ /// return None, otherwise return `nullptr`. Same as the public version
+ /// except that it can be used without recording dependences on any \p AA.
+ Optional<Value *> getAssumedSimplified(const IRPosition &V,
+ const AbstractAttribute *AA,
+ bool &UsedAssumedInformation);
+
/// Register \p CB as a simplification callback.
/// `Attributor::getAssumedSimplified` will use these callbacks before
/// we it will ask `AAValueSimplify`. It is important to ensure this
@@ -1561,13 +1568,6 @@ struct Attributor {
DenseMap<IRPosition, SmallVector<SimplifictionCallbackTy, 1>>
SimplificationCallbacks;
- /// If \p V is assumed simplified, return it, if it is unclear yet,
- /// return None, otherwise return `nullptr`. Same as the public version
- /// except that it can be used without recording dependences on any \p AA.
- Optional<Value *> getAssumedSimplified(const IRPosition &V,
- const AbstractAttribute *AA,
- bool &UsedAssumedInformation);
-
public:
/// Translate \p V from the callee context into the call site context.
Optional<Value *>
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 9150d951daa6..9f98902105cc 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -3991,11 +3991,23 @@ void OpenMPOpt::registerAAs(bool IsModulePass) {
// Create an ExecutionDomain AA for every function and a HeapToStack AA for
// every function if there is a device kernel.
+ if (!isOpenMPDevice(M))
+ return;
+
for (auto *F : SCC) {
- if (!F->isDeclaration())
- A.getOrCreateAAFor<AAExecutionDomain>(IRPosition::function(*F));
- if (isOpenMPDevice(M))
- A.getOrCreateAAFor<AAHeapToStack>(IRPosition::function(*F));
+ if (F->isDeclaration())
+ continue;
+
+ A.getOrCreateAAFor<AAExecutionDomain>(IRPosition::function(*F));
+ A.getOrCreateAAFor<AAHeapToStack>(IRPosition::function(*F));
+
+ for (auto &I : instructions(*F)) {
+ if (auto *LI = dyn_cast<LoadInst>(&I)) {
+ bool UsedAssumedInformation = false;
+ A.getAssumedSimplified(IRPosition::value(*LI), /* AA */ nullptr,
+ UsedAssumedInformation);
+ }
+ }
}
}
More information about the llvm-commits
mailing list