From e30fbbe9a5359f5d88fbc6045f320a120fc9a5af Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Mon, 4 Jan 2021 13:04:09 -0800 Subject: [PATCH] [JumpThreading][NewPM] Skip when target has divergent CF Matches the legacy pass. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D94028 --- llvm/lib/Transforms/Scalar/JumpThreading.cpp | 4 ++++ llvm/test/Transforms/JumpThreading/divergent-target-test.ll | 2 ++ 2 files changed, 6 insertions(+) diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index ce191144297b..e8de6f425db6 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -341,6 +341,10 @@ bool JumpThreading::runOnFunction(Function &F) { PreservedAnalyses JumpThreadingPass::run(Function &F, FunctionAnalysisManager &AM) { + auto &TTI = AM.getResult(F); + // Jump Threading has no sense for the targets with divergent CF + if (TTI.hasBranchDivergence()) + return PreservedAnalyses::all(); auto &TLI = AM.getResult(F); auto &DT = AM.getResult(F); auto &LVI = AM.getResult(F); diff --git a/llvm/test/Transforms/JumpThreading/divergent-target-test.ll b/llvm/test/Transforms/JumpThreading/divergent-target-test.ll index 4f7d237691c8..34060fbb09d9 100644 --- a/llvm/test/Transforms/JumpThreading/divergent-target-test.ll +++ b/llvm/test/Transforms/JumpThreading/divergent-target-test.ll @@ -1,6 +1,8 @@ ; REQUIRES: amdgpu-registered-target && x86-registered-target ; RUN: opt < %s -mtriple=amdgcn -jump-threading -S | FileCheck %s -check-prefixes=CHECK,DIVERGENT +; RUN: opt < %s -mtriple=amdgcn -passes=jump-threading -S | FileCheck %s -check-prefixes=CHECK,DIVERGENT ; RUN: opt < %s -mtriple=x86_64 -jump-threading -S | FileCheck %s -check-prefixes=CHECK,UNIFORM +; RUN: opt < %s -mtriple=x86_64 -passes=jump-threading -S | FileCheck %s -check-prefixes=CHECK,UNIFORM ; Here we assure that for the target with no branch divergence usual Jump Threading optimization performed ; For target with branch divergence - no optimization, so the IR is unchanged. -- 2.34.1