Skip to content

Commit

Permalink
Allow instruction combine (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte authored Nov 19, 2024
1 parent 26ccb0c commit 77c4da7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 137 deletions.
42 changes: 0 additions & 42 deletions llvm/lib/Target/SBF/SBFAdjustOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
using namespace llvm;
using namespace llvm::PatternMatch;

static cl::opt<bool>
DisableSBFserializeICMP("sbf-disable-serialize-icmp", cl::Hidden,
cl::desc("SBF: Disable Serializing ICMP insns."),
cl::init(false));

static cl::opt<bool> DisableSBFavoidSpeculation(
"sbf-disable-avoid-speculation", cl::Hidden,
cl::desc("SBF: Disable Avoiding Speculative Code Motion."),
Expand All @@ -58,7 +53,6 @@ class SBFAdjustOptImpl {
SmallVector<PassThroughInfo, 16> PassThroughs;

void adjustInst(Instruction &I);
bool serializeICMPInBB(Instruction &I);
bool avoidSpeculation(Instruction &I);
bool insertPassThrough();
};
Expand All @@ -84,40 +78,6 @@ bool SBFAdjustOptImpl::insertPassThrough() {
return !PassThroughs.empty();
}

// To avoid combining conditionals in the same basic block by
// instrcombine optimization.
bool SBFAdjustOptImpl::serializeICMPInBB(Instruction &I) {
// For:
// comp1 = icmp <opcode> ...;
// comp2 = icmp <opcode> ...;
// ... or comp1 comp2 ...
// changed to:
// comp1 = icmp <opcode> ...;
// comp2 = icmp <opcode> ...;
// new_comp1 = __builtin_bpf_passthrough(seq_num, comp1)
// ... or new_comp1 comp2 ...
Value *Op0, *Op1;
// Use LogicalOr (accept `or i1` as well as `select i1 Op0, true, Op1`)
if (!match(&I, m_LogicalOr(m_Value(Op0), m_Value(Op1))))
return false;
auto *Icmp1 = dyn_cast<ICmpInst>(Op0);
if (!Icmp1)
return false;
auto *Icmp2 = dyn_cast<ICmpInst>(Op1);
if (!Icmp2)
return false;

Value *Icmp1Op0 = Icmp1->getOperand(0);
Value *Icmp2Op0 = Icmp2->getOperand(0);
if (Icmp1Op0 != Icmp2Op0)
return false;

// Now we got two icmp instructions which feed into
// an "or" instruction.
PassThroughInfo Info(Icmp1, &I, 0);
PassThroughs.push_back(Info);
return true;
}

// To avoid speculative hoisting certain computations out of
// a basic block.
Expand Down Expand Up @@ -215,8 +175,6 @@ bool SBFAdjustOptImpl::avoidSpeculation(Instruction &I) {
}

void SBFAdjustOptImpl::adjustInst(Instruction &I) {
if (!DisableSBFserializeICMP && serializeICMPInBB(I))
return;
if (!DisableSBFavoidSpeculation && avoidSpeculation(I))
return;
}
Expand Down
95 changes: 0 additions & 95 deletions llvm/test/CodeGen/SBF/adjust-opt-icmp1.ll

This file was deleted.

0 comments on commit 77c4da7

Please sign in to comment.