Skip to content

JIT: fix permute node type in AVX simd sum #103680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2024
Merged
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
14 changes: 13 additions & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5701,12 +5701,20 @@ void Compiler::SplitTreesRandomly()
rng.Init(info.compMethodHash() ^ 0x077cc4d4);

// Splitting creates a lot of new locals. Set a limit on how many we end up creating here.
unsigned maxLvaCount = max(lvaCount * 2, 50000u);
unsigned maxLvaCount = max(lvaCount * 2, 50000u);
int numSplit = 0;
const int splitLimit = JitConfig.JitStressSplitTreeLimit();

for (BasicBlock* block : Blocks())
{
for (Statement* stmt : block->NonPhiStatements())
{
if ((splitLimit >= 0) && (numSplit >= splitLimit))
{
JITDUMP("Reached split limit (%d) -- stopping\n", splitLimit);
return;
}

int numTrees = 0;
for (GenTree* tree : stmt->TreeList())
{
Expand Down Expand Up @@ -5739,6 +5747,7 @@ void Compiler::SplitTreesRandomly()

fgMorphStmtBlockOps(block, stmt);
gtUpdateStmtSideEffects(stmt);
numSplit++;
}

break;
Expand All @@ -5754,6 +5763,9 @@ void Compiler::SplitTreesRandomly()
}
}
}

JITDUMP("Split %d trees\n", numSplit);

#endif
}

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26307,13 +26307,13 @@ GenTree* Compiler::gtNewSimdSumNode(var_types type, GenTree* op1, CorInfoType si
{
assert(compIsaSupportedDebugOnly(InstructionSet_AVX));
// The permute below gives us [0, 1, 2, 3] -> [1, 0, 3, 2]
op1 = gtNewSimdHWIntrinsicNode(type, op1, gtNewIconNode((int)0b10110001, TYP_INT), NI_AVX_Permute,
op1 = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, gtNewIconNode((int)0b10110001, TYP_INT), NI_AVX_Permute,
simdBaseJitType, simdSize);
// The add below now results in [0 + 1, 1 + 0, 2 + 3, 3 + 2]
op1 = gtNewSimdBinOpNode(GT_ADD, TYP_SIMD16, op1, op1Shuffled, simdBaseJitType, simdSize);
op1Shuffled = fgMakeMultiUse(&op1);
// The permute below gives us [0 + 1, 1 + 0, 2 + 3, 3 + 2] -> [2 + 3, 3 + 2, 0 + 1, 1 + 0]
op1 = gtNewSimdHWIntrinsicNode(type, op1, gtNewIconNode((int)0b01001110, TYP_INT), NI_AVX_Permute,
op1 = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, gtNewIconNode((int)0b01001110, TYP_INT), NI_AVX_Permute,
simdBaseJitType, simdSize);
}
else
Expand Down Expand Up @@ -26345,7 +26345,7 @@ GenTree* Compiler::gtNewSimdSumNode(var_types type, GenTree* op1, CorInfoType si
{
assert(compIsaSupportedDebugOnly(InstructionSet_AVX));
// The permute below gives us [0, 1] -> [1, 0]
op1 = gtNewSimdHWIntrinsicNode(type, op1, gtNewIconNode((int)0b0001, TYP_INT), NI_AVX_Permute,
op1 = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, gtNewIconNode((int)0b0001, TYP_INT), NI_AVX_Permute,
simdBaseJitType, simdSize);
}
else
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ CONFIG_INTEGER(JitStressProcedureSplitting, W("JitStressProcedureSplitting"), 0)
CONFIG_INTEGER(JitStressRegs, W("JitStressRegs"), 0)
CONFIG_STRING(JitStressRegsRange, W("JitStressRegsRange")) // Only apply JitStressRegs to methods in this hash range

// If non-negative value N, only stress split the first N trees.
CONFIG_INTEGER(JitStressSplitTreeLimit, W("JitStressSplitTreeLimit"), -1)

// If non-zero, assert if # of VNF_MapSelect applications considered reaches this.
CONFIG_INTEGER(JitVNMapSelLimit, W("JitVNMapSelLimit"), 0)

Expand Down
Loading