Skip to content

Commit

Permalink
[X86] combineX86ShufflesConstants - move hasOneUse check as late as p…
Browse files Browse the repository at this point in the history
…ossible. NFC.

We only need to check hasOneUse if we're optimizing for size, so move the call at the end of the if check.
  • Loading branch information
RKSimon committed Apr 2, 2023
1 parent b18835f commit 741298a
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40532,22 +40532,19 @@ static SDValue combineX86ShufflesConstants(ArrayRef<SDValue> Ops,
unsigned NumOps = Ops.size();

// Extract constant bits from each source op.
bool OneUseConstantOp = false;
SmallVector<APInt, 16> UndefEltsOps(NumOps);
SmallVector<SmallVector<APInt, 16>, 16> RawBitsOps(NumOps);
for (unsigned i = 0; i != NumOps; ++i) {
SDValue SrcOp = Ops[i];
OneUseConstantOp |= SrcOp.hasOneUse();
if (!getTargetConstantBitsFromNode(SrcOp, MaskSizeInBits, UndefEltsOps[i],
RawBitsOps[i]))
for (unsigned I = 0; I != NumOps; ++I)
if (!getTargetConstantBitsFromNode(Ops[I], MaskSizeInBits, UndefEltsOps[I],
RawBitsOps[I]))
return SDValue();
}

// If we're optimizing for size, only fold if at least one of the constants is
// only used once or the combined shuffle has included a variable mask
// shuffle, this is to avoid constant pool bloat.
bool IsOptimizingSize = DAG.shouldOptForSize();
if (IsOptimizingSize && !OneUseConstantOp && !HasVariableMask)
if (IsOptimizingSize && !HasVariableMask &&
llvm::none_of(Ops, [](SDValue SrcOp) { return SrcOp->hasOneUse(); }))
return SDValue();

// Shuffle the constant bits according to the mask.
Expand Down

0 comments on commit 741298a

Please sign in to comment.