Skip to content

Commit 487c4f3

Browse files
committed
Split --simplifycfg-hoist-loads-stores-with-cond-faulting
1 parent 0e15983 commit 487c4f3

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,20 @@ static cl::opt<bool>
120120
HoistCommon("simplifycfg-hoist-common", cl::Hidden, cl::init(true),
121121
cl::desc("Hoist common instructions up to the parent block"));
122122

123-
static cl::opt<bool> HoistLoadsStoresWithCondFaulting(
124-
"simplifycfg-hoist-loads-stores-with-cond-faulting", cl::Hidden,
125-
cl::init(true),
126-
cl::desc("Hoist loads/stores if the target supports "
127-
"conditional faulting"));
123+
static cl::opt<bool> HoistLoadsWithCondFaulting(
124+
"simplifycfg-hoist-loads-with-cond-faulting", cl::Hidden, cl::init(true),
125+
cl::desc("Hoist loads if the target supports conditional faulting"));
126+
127+
static cl::opt<bool> HoistStoresWithCondFaulting(
128+
"simplifycfg-hoist-stores-with-cond-faulting", cl::Hidden, cl::init(true),
129+
cl::desc("Hoist stores if the target supports conditional faulting"));
128130

129131
static cl::opt<unsigned> HoistLoadsStoresWithCondFaultingThreshold(
130132
"hoist-loads-stores-with-cond-faulting-threshold", cl::Hidden, cl::init(6),
131133
cl::desc("Control the maximal conditional load/store that we are willing "
132134
"to speculatively execute to eliminate conditional branch "
133135
"(default = 6)"));
134136

135-
static cl::opt<unsigned> DisableCloadCstore(
136-
"disable-cload-cstore", cl::Hidden, cl::init(0),
137-
cl::desc("Control to disable cond-faulting-load(1)/cond-faulting-store(2)"
138-
"/all(3)"));
139-
140137
static cl::opt<unsigned>
141138
HoistCommonSkipLimit("simplifycfg-hoist-common-skip-limit", cl::Hidden,
142139
cl::init(20),
@@ -1781,10 +1778,10 @@ static bool isSafeCheapLoadStore(const Instruction *I,
17811778
const TargetTransformInfo &TTI) {
17821779
// Not handle volatile or atomic.
17831780
if (auto *L = dyn_cast<LoadInst>(I)) {
1784-
if (!L->isSimple() || (DisableCloadCstore & 1))
1781+
if (!L->isSimple() || !HoistLoadsWithCondFaulting)
17851782
return false;
17861783
} else if (auto *S = dyn_cast<StoreInst>(I)) {
1787-
if (!S->isSimple() || (DisableCloadCstore & 2))
1784+
if (!S->isSimple() || !HoistStoresWithCondFaulting)
17881785
return false;
17891786
} else
17901787
return false;
@@ -3224,8 +3221,7 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
32243221
SmallVector<Instruction *, 4> SpeculatedDbgIntrinsics;
32253222

32263223
unsigned SpeculatedInstructions = 0;
3227-
bool HoistLoadsStores = HoistLoadsStoresWithCondFaulting &&
3228-
Options.HoistLoadsStoresWithCondFaulting;
3224+
bool HoistLoadsStores = Options.HoistLoadsStoresWithCondFaulting;
32293225
SmallVector<Instruction *, 2> SpeculatedConditionalLoadsStores;
32303226
Value *SpeculatedStoreValue = nullptr;
32313227
StoreInst *SpeculatedStore = nullptr;
@@ -8033,8 +8029,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
80338029
hoistCommonCodeFromSuccessors(BI, !Options.HoistCommonInsts))
80348030
return requestResimplify();
80358031

8036-
if (BI && HoistLoadsStoresWithCondFaulting &&
8037-
Options.HoistLoadsStoresWithCondFaulting &&
8032+
if (BI && Options.HoistLoadsStoresWithCondFaulting &&
80388033
isProfitableToSpeculate(BI, std::nullopt, TTI)) {
80398034
SmallVector<Instruction *, 2> SpeculatedConditionalLoadsStores;
80408035
auto CanSpeculateConditionalLoadsStores = [&]() {

llvm/test/Transforms/SimplifyCFG/X86/hoist-loads-stores-with-cf.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s --check-prefixes=CHECK,LOADSTORE
3-
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -disable-cload-cstore=0 -S | FileCheck %s --check-prefixes=CHECK,LOADSTORE
4-
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -disable-cload-cstore=1 -S | FileCheck %s --check-prefixes=CHECK,NONE,STOREONLY
5-
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -disable-cload-cstore=2 -S | FileCheck %s --check-prefixes=CHECK,NONE,LOADONLY
6-
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -disable-cload-cstore=3 -S | FileCheck %s --check-prefixes=CHECK,NONE,NONEONLY
3+
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -simplifycfg-hoist-loads-with-cond-faulting=false -S | FileCheck %s --check-prefixes=CHECK,NONE,STOREONLY
4+
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -simplifycfg-hoist-stores-with-cond-faulting=false -S | FileCheck %s --check-prefixes=CHECK,NONE,LOADONLY
5+
; RUN: opt < %s -mtriple=x86_64 -mattr=+cf -passes='simplifycfg<hoist-loads-stores-with-cond-faulting>' -simplifycfg-require-and-preserve-domtree=1 -simplifycfg-hoist-stores-with-cond-faulting=false -simplifycfg-hoist-loads-with-cond-faulting=false -S | FileCheck %s --check-prefixes=CHECK,NONE,NONEONLY
76

87
;; Basic case: check masked.load/store is generated for i16/i32/i64.
98
define void @basic(i1 %cond, ptr %b, ptr %p, ptr %q) {

0 commit comments

Comments
 (0)