Skip to content

Commit c0d569c

Browse files
committed
[SOL] Remove code adjustment (llvm#98)
1 parent 8c419a4 commit c0d569c

File tree

4 files changed

+0
-328
lines changed

4 files changed

+0
-328
lines changed

llvm/lib/Target/SBF/SBFAdjustOpt.cpp

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ class SBFAdjustOptImpl {
5757
Module *M;
5858
SmallVector<PassThroughInfo, 16> PassThroughs;
5959

60-
void adjustBasicBlock(BasicBlock &BB);
61-
bool serializeICMPCrossBB(BasicBlock &BB);
6260
void adjustInst(Instruction &I);
6361
bool serializeICMPInBB(Instruction &I);
6462
bool avoidSpeculation(Instruction &I);
@@ -70,7 +68,6 @@ class SBFAdjustOptImpl {
7068
bool SBFAdjustOptImpl::run() {
7169
for (Function &F : *M)
7270
for (auto &BB : F) {
73-
adjustBasicBlock(BB);
7471
for (auto &I : BB)
7572
adjustInst(I);
7673
}
@@ -122,86 +119,6 @@ bool SBFAdjustOptImpl::serializeICMPInBB(Instruction &I) {
122119
return true;
123120
}
124121

125-
// To avoid combining conditionals in the same basic block by
126-
// instrcombine optimization.
127-
bool SBFAdjustOptImpl::serializeICMPCrossBB(BasicBlock &BB) {
128-
// For:
129-
// B1:
130-
// comp1 = icmp <opcode> ...;
131-
// if (comp1) goto B2 else B3;
132-
// B2:
133-
// comp2 = icmp <opcode> ...;
134-
// if (comp2) goto B4 else B5;
135-
// B4:
136-
// ...
137-
// changed to:
138-
// B1:
139-
// comp1 = icmp <opcode> ...;
140-
// comp1 = __builtin_bpf_passthrough(seq_num, comp1);
141-
// if (comp1) goto B2 else B3;
142-
// B2:
143-
// comp2 = icmp <opcode> ...;
144-
// if (comp2) goto B4 else B5;
145-
// B4:
146-
// ...
147-
148-
// Check basic predecessors, if two of them (say B1, B2) are using
149-
// icmp instructions to generate conditions and one is the predesessor
150-
// of another (e.g., B1 is the predecessor of B2). Add a passthrough
151-
// barrier after icmp inst of block B1.
152-
BasicBlock *B2 = BB.getSinglePredecessor();
153-
if (!B2)
154-
return false;
155-
156-
BasicBlock *B1 = B2->getSinglePredecessor();
157-
if (!B1)
158-
return false;
159-
160-
Instruction *TI = B2->getTerminator();
161-
auto *BI = dyn_cast<BranchInst>(TI);
162-
if (!BI || !BI->isConditional())
163-
return false;
164-
auto *Cond = dyn_cast<ICmpInst>(BI->getCondition());
165-
if (!Cond || B2->getFirstNonPHI() != Cond)
166-
return false;
167-
Value *B2Op0 = Cond->getOperand(0);
168-
auto Cond2Op = Cond->getPredicate();
169-
170-
TI = B1->getTerminator();
171-
BI = dyn_cast<BranchInst>(TI);
172-
if (!BI || !BI->isConditional())
173-
return false;
174-
Cond = dyn_cast<ICmpInst>(BI->getCondition());
175-
if (!Cond)
176-
return false;
177-
Value *B1Op0 = Cond->getOperand(0);
178-
auto Cond1Op = Cond->getPredicate();
179-
180-
if (B1Op0 != B2Op0)
181-
return false;
182-
183-
if (Cond1Op == ICmpInst::ICMP_SGT || Cond1Op == ICmpInst::ICMP_SGE) {
184-
if (Cond2Op != ICmpInst::ICMP_SLT && Cond2Op != ICmpInst::ICMP_SLE)
185-
return false;
186-
} else if (Cond1Op == ICmpInst::ICMP_SLT || Cond1Op == ICmpInst::ICMP_SLE) {
187-
if (Cond2Op != ICmpInst::ICMP_SGT && Cond2Op != ICmpInst::ICMP_SGE)
188-
return false;
189-
} else if (Cond1Op == ICmpInst::ICMP_ULT || Cond1Op == ICmpInst::ICMP_ULE) {
190-
if (Cond2Op != ICmpInst::ICMP_UGT && Cond2Op != ICmpInst::ICMP_UGE)
191-
return false;
192-
} else if (Cond1Op == ICmpInst::ICMP_UGT || Cond1Op == ICmpInst::ICMP_UGE) {
193-
if (Cond2Op != ICmpInst::ICMP_ULT && Cond2Op != ICmpInst::ICMP_ULE)
194-
return false;
195-
} else {
196-
return false;
197-
}
198-
199-
PassThroughInfo Info(Cond, BI, 0);
200-
PassThroughs.push_back(Info);
201-
202-
return true;
203-
}
204-
205122
// To avoid speculative hoisting certain computations out of
206123
// a basic block.
207124
bool SBFAdjustOptImpl::avoidSpeculation(Instruction &I) {
@@ -297,11 +214,6 @@ bool SBFAdjustOptImpl::avoidSpeculation(Instruction &I) {
297214
return true;
298215
}
299216

300-
void SBFAdjustOptImpl::adjustBasicBlock(BasicBlock &BB) {
301-
if (!DisableSBFserializeICMP && serializeICMPCrossBB(BB))
302-
return;
303-
}
304-
305217
void SBFAdjustOptImpl::adjustInst(Instruction &I) {
306218
if (!DisableSBFserializeICMP && serializeICMPInBB(I))
307219
return;

llvm/test/CodeGen/SBF/adjust-opt-icmp2.ll

Lines changed: 0 additions & 98 deletions
This file was deleted.

llvm/test/CodeGen/SBF/adjust-opt-icmp5.ll

Lines changed: 0 additions & 71 deletions
This file was deleted.

llvm/test/CodeGen/SBF/adjust-opt-icmp6.ll

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)