[PATCH] D93302: Disable Jump Threading for the targets with divergent control flow

Alexander via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 08:17:36 PST 2020


alex-t created this revision.
Herald added a subscriber: hiraditya.
alex-t requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Details: Jump Threading does not make sense for the targets with divergent CF

  since they do not use branch prediction for speculative execution.
  Also in the high level IR there is no enough information to conclude that the branch is divergent or unniform.
  This may cause errors in further CF lowering.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93302

Files:
  llvm/lib/Transforms/Scalar/JumpThreading.cpp


Index: llvm/lib/Transforms/Scalar/JumpThreading.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -32,6 +32,7 @@
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
@@ -153,6 +154,7 @@
       AU.addPreserved<LazyValueInfoWrapperPass>();
       AU.addPreserved<GlobalsAAWrapperPass>();
       AU.addRequired<TargetLibraryInfoWrapperPass>();
+      AU.addRequired<TargetTransformInfoWrapperPass>();
     }
 
     void releaseMemory() override { Impl.releaseMemory(); }
@@ -311,6 +313,10 @@
 bool JumpThreading::runOnFunction(Function &F) {
   if (skipFunction(F))
     return false;
+  auto TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
+  // Jump Threading has no sense for the targets with divergent CF
+  if (TTI->hasBranchDivergence())
+    return false;
   auto TLI = &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
   auto DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
   auto LVI = &getAnalysis<LazyValueInfoWrapperPass>().getLVI();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93302.311916.patch
Type: text/x-patch
Size: 1315 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201215/0df9da4a/attachment.bin>


More information about the llvm-commits mailing list