[llvm] [GVN] Disable GVN PRE on target hasBranchDivergence (PR #77069)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 5 02:06:41 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: fengfeng (fengfeng09)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/77069.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/GVN.cpp (+5) 


``````````diff
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index e36578f3de7ac4..777dec04faf9f6 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -41,6 +41,7 @@
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/PHITransAddr.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -750,6 +751,10 @@ bool GVNPass::isMemDepEnabled() const {
 }
 
 PreservedAnalyses GVNPass::run(Function &F, FunctionAnalysisManager &AM) {
+  // Disable PRE on GPU.
+  auto &TTI = AM.getResult<TargetIRAnalysis>(F);
+  if (TTI.hasBranchDivergence())
+    GVNEnablePRE = false;
   // FIXME: The order of evaluation of these 'getResult' calls is very
   // significant! Re-ordering these variables will cause GVN when run alone to
   // be less effective! We should fix memdep and basic-aa to not exhibit this

``````````

</details>


https://github.com/llvm/llvm-project/pull/77069


More information about the llvm-commits mailing list