diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/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(); AU.addPreserved(); AU.addRequired(); + AU.addRequired(); } void releaseMemory() override { Impl.releaseMemory(); } @@ -311,6 +313,10 @@ bool JumpThreading::runOnFunction(Function &F) { if (skipFunction(F)) return false; + auto TTI = &getAnalysis().getTTI(F); + // Jump Threading has no sense for the targets with divergent CF + if (TTI->hasBranchDivergence()) + return false; auto TLI = &getAnalysis().getTLI(F); auto DT = &getAnalysis().getDomTree(); auto LVI = &getAnalysis().getLVI();