Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions llvm/lib/Target/X86/X86TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7198,6 +7198,28 @@ bool X86TTIImpl::isProfitableToSinkOperands(Instruction *I,
SmallVectorImpl<Use *> &Ops) const {
using namespace llvm::PatternMatch;

if (I->getOpcode() == Instruction::And &&
(ST->hasBMI() || (I->getType()->isVectorTy() && ST->hasSSE2()))) {
for (auto &Op : I->operands()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't pattern match do the commutative matching m_c_And()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_c_And() doesn't tell us which of the two operands is a not and we need to return the Use of not in Ops.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feasible to add a PatternMatch::m_Use(Use *&U) matcher?

// (and X, (not Y)) -> (andn X, Y)
if (match(Op.get(), m_Not(m_Value()))) {
Ops.push_back(&Op);
return true;
}
// (and X, (splat (not Y))) -> (andn X, (splat Y))
if (match(Op.get(),
m_Shuffle(m_InsertElt(m_Value(), m_Not(m_Value()), m_ZeroInt()),
m_Value(), m_ZeroMask()))) {
Use &InsertElt = cast<Instruction>(Op)->getOperandUse(0);
Use &Not = cast<Instruction>(InsertElt)->getOperandUse(1);
Ops.push_back(&Not);
Ops.push_back(&InsertElt);
Ops.push_back(&Op);
return true;
}
}
}

FixedVectorType *VTy = dyn_cast<FixedVectorType>(I->getType());
if (!VTy)
return false;
Expand Down
Loading