Skip to content

Commit c1d6262

Browse files
Ensure we call genProduceReg for the embedded mask node (#103024)
1 parent 909db28 commit c1d6262

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/coreclr/jit/hwintrinsiccodegenxarch.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
180180
CORINFO_InstructionSet isa = HWIntrinsicInfo::lookupIsa(intrinsicId);
181181
HWIntrinsicCategory category = HWIntrinsicInfo::lookupCategory(intrinsicId);
182182
size_t numArgs = node->GetOperandCount();
183+
GenTree* embMaskNode = nullptr;
183184
GenTree* embMaskOp = nullptr;
184185

185186
// We need to validate that other phases of the compiler haven't introduced unsupported intrinsics
@@ -233,6 +234,9 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
233234
op2->ClearContained();
234235
op2->SetRegNum(targetReg);
235236

237+
// Track the original mask node so we can call genProduceReg
238+
embMaskNode = node;
239+
236240
// Fixup all the already initialized variables
237241
node = op2->AsHWIntrinsic();
238242
intrinsicId = node->GetHWIntrinsicId();
@@ -696,13 +700,27 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
696700
// Handle an extra operand we need to consume so that
697701
// embedded masking can work without making the overall
698702
// logic significantly more complex.
703+
704+
assert(embMaskNode != nullptr);
699705
genConsumeReg(embMaskOp);
700706
}
701707

702708
genProduceReg(node);
709+
710+
if (embMaskNode != nullptr)
711+
{
712+
// Similarly to the mask operand, we need to handle the
713+
// mask node to ensure everything works correctly, particularly
714+
// lifetimes and spilling if required. Doing it this way avoids
715+
// needing to duplicate all our existing handling.
716+
717+
assert(embMaskOp != nullptr);
718+
genProduceReg(embMaskNode);
719+
}
703720
return;
704721
}
705722

723+
assert(embMaskNode == nullptr);
706724
assert(embMaskOp == nullptr);
707725

708726
switch (isa)

0 commit comments

Comments
 (0)