Skip to content

Commit cdd1cd7

Browse files
committed
[X86] Don't form masked instructions if the operation has an additional user.
This will cause the operation to be repeated in both a mask and another masked or unmasked form. This can a wasted of execution resources. Differential Revision: https://reviews.llvm.org/D60940
1 parent c682488 commit cdd1cd7

File tree

4 files changed

+353
-311
lines changed

4 files changed

+353
-311
lines changed

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ namespace {
259259
SDValue &Index, SDValue &Disp,
260260
SDValue &Segment);
261261

262+
bool isProfitableToFormMaskedOp(SDNode *N) const;
263+
262264
/// Implement addressing mode selection for inline asm expressions.
263265
bool SelectInlineAsmMemoryOperand(const SDValue &Op,
264266
unsigned ConstraintID,
@@ -722,6 +724,20 @@ X86DAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const {
722724
return true;
723725
}
724726

727+
// Indicates it is profitable to form an AVX512 masked operation. Returning
728+
// false will favor a masked register-register masked move or vblendm and the
729+
// operation will be selected separately.
730+
bool X86DAGToDAGISel::isProfitableToFormMaskedOp(SDNode *N) const {
731+
assert(
732+
(N->getOpcode() == ISD::VSELECT || N->getOpcode() == X86ISD::SELECTS) &&
733+
"Unexpected opcode!");
734+
735+
// If the operation has additional users, the operation will be duplicated.
736+
// Check the use count to prevent that.
737+
// FIXME: Are there cheap opcodes we might want to duplicate?
738+
return N->getOperand(1).hasOneUse();
739+
}
740+
725741
/// Replace the original chain operand of the call with
726742
/// load's chain operand and move load below the call's chain operand.
727743
static void moveBelowOrigChain(SelectionDAG *CurDAG, SDValue Load,

0 commit comments

Comments
 (0)