Skip to content

Commit 594b92a

Browse files
[RISCV] Add Tune to DontSinkSplatOperands (#79199)
A CPU may prefer to not sink splat operands, one reason being that it could require a S2V transfer buffer to move scalars into buffers.
1 parent a315fb1 commit 594b92a

File tree

3 files changed

+669
-0
lines changed

3 files changed

+669
-0
lines changed

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,13 @@ def TuneShortForwardBranchOpt
10741074
def HasShortForwardBranchOpt : Predicate<"Subtarget->hasShortForwardBranchOpt()">;
10751075
def NoShortForwardBranchOpt : Predicate<"!Subtarget->hasShortForwardBranchOpt()">;
10761076

1077+
// Some subtargets require a S2V transfer buffer to move scalars into vectors.
1078+
// FIXME: Forming .vx/.vf/.wx/.wf can reduce register pressure.
1079+
def TuneNoSinkSplatOperands
1080+
: SubtargetFeature<"no-sink-splat-operands", "SinkSplatOperands",
1081+
"false", "Disable sink splat operands to enable .vx, .vf,"
1082+
".wx, and .wf instructions">;
1083+
10771084
def TuneConditionalCompressedMoveFusion
10781085
: SubtargetFeature<"conditional-cmv-fusion", "HasConditionalCompressedMoveFusion",
10791086
"true", "Enable branch+c.mv fusion">;

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,14 @@ bool RISCVTargetLowering::shouldSinkOperands(
20022002
if (!I->getType()->isVectorTy() || !Subtarget.hasVInstructions())
20032003
return false;
20042004

2005+
// Don't sink splat operands if the target prefers it. Some targets requires
2006+
// S2V transfer buffers and we can run out of them copying the same value
2007+
// repeatedly.
2008+
// FIXME: It could still be worth doing if it would improve vector register
2009+
// pressure and prevent a vector spill.
2010+
if (!Subtarget.sinkSplatOperands())
2011+
return false;
2012+
20052013
for (auto OpIdx : enumerate(I->operands())) {
20062014
if (!canSplatOperand(I, OpIdx.index()))
20072015
continue;

0 commit comments

Comments
 (0)