Skip to content

Commit ff8789f

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

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,22 @@ 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,
123+
static cl::opt<bool> HoistLoadsWithCondFaulting(
124+
"simplifycfg-hoist-loads-with-cond-faulting", cl::Hidden,
125125
cl::init(true),
126-
cl::desc("Hoist loads/stores if the target supports "
127-
"conditional faulting"));
126+
cl::desc("Hoist loads if the target supports conditional faulting"));
127+
128+
static cl::opt<bool> HoistStoresWithCondFaulting(
129+
"simplifycfg-hoist-stores-with-cond-faulting", cl::Hidden,
130+
cl::init(true),
131+
cl::desc("Hoist stores if the target supports conditional faulting"));
128132

129133
static cl::opt<unsigned> HoistLoadsStoresWithCondFaultingThreshold(
130134
"hoist-loads-stores-with-cond-faulting-threshold", cl::Hidden, cl::init(6),
131135
cl::desc("Control the maximal conditional load/store that we are willing "
132136
"to speculatively execute to eliminate conditional branch "
133137
"(default = 6)"));
134138

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-
140139
static cl::opt<unsigned>
141140
HoistCommonSkipLimit("simplifycfg-hoist-common-skip-limit", cl::Hidden,
142141
cl::init(20),
@@ -1781,10 +1780,10 @@ static bool isSafeCheapLoadStore(const Instruction *I,
17811780
const TargetTransformInfo &TTI) {
17821781
// Not handle volatile or atomic.
17831782
if (auto *L = dyn_cast<LoadInst>(I)) {
1784-
if (!L->isSimple() || (DisableCloadCstore & 1))
1783+
if (!L->isSimple() || !HoistLoadsWithCondFaulting)
17851784
return false;
17861785
} else if (auto *S = dyn_cast<StoreInst>(I)) {
1787-
if (!S->isSimple() || (DisableCloadCstore & 2))
1786+
if (!S->isSimple() || !HoistStoresWithCondFaulting)
17881787
return false;
17891788
} else
17901789
return false;
@@ -3224,8 +3223,7 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
32243223
SmallVector<Instruction *, 4> SpeculatedDbgIntrinsics;
32253224

32263225
unsigned SpeculatedInstructions = 0;
3227-
bool HoistLoadsStores = HoistLoadsStoresWithCondFaulting &&
3228-
Options.HoistLoadsStoresWithCondFaulting;
3226+
bool HoistLoadsStores = Options.HoistLoadsStoresWithCondFaulting;
32293227
SmallVector<Instruction *, 2> SpeculatedConditionalLoadsStores;
32303228
Value *SpeculatedStoreValue = nullptr;
32313229
StoreInst *SpeculatedStore = nullptr;
@@ -8033,8 +8031,7 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
80338031
hoistCommonCodeFromSuccessors(BI, !Options.HoistCommonInsts))
80348032
return requestResimplify();
80358033

8036-
if (BI && HoistLoadsStoresWithCondFaulting &&
8037-
Options.HoistLoadsStoresWithCondFaulting &&
8034+
if (BI && Options.HoistLoadsStoresWithCondFaulting &&
80388035
isProfitableToSpeculate(BI, std::nullopt, TTI)) {
80398036
SmallVector<Instruction *, 2> SpeculatedConditionalLoadsStores;
80408037
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)