@@ -180,6 +180,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
180
180
CORINFO_InstructionSet isa = HWIntrinsicInfo::lookupIsa (intrinsicId);
181
181
HWIntrinsicCategory category = HWIntrinsicInfo::lookupCategory (intrinsicId);
182
182
size_t numArgs = node->GetOperandCount ();
183
+ GenTree* embMaskNode = nullptr ;
183
184
GenTree* embMaskOp = nullptr ;
184
185
185
186
// We need to validate that other phases of the compiler haven't introduced unsupported intrinsics
@@ -233,6 +234,9 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
233
234
op2->ClearContained ();
234
235
op2->SetRegNum (targetReg);
235
236
237
+ // Track the original mask node so we can call genProduceReg
238
+ embMaskNode = node;
239
+
236
240
// Fixup all the already initialized variables
237
241
node = op2->AsHWIntrinsic ();
238
242
intrinsicId = node->GetHWIntrinsicId ();
@@ -696,13 +700,27 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
696
700
// Handle an extra operand we need to consume so that
697
701
// embedded masking can work without making the overall
698
702
// logic significantly more complex.
703
+
704
+ assert (embMaskNode != nullptr );
699
705
genConsumeReg (embMaskOp);
700
706
}
701
707
702
708
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
+ }
703
720
return ;
704
721
}
705
722
723
+ assert (embMaskNode == nullptr );
706
724
assert (embMaskOp == nullptr );
707
725
708
726
switch (isa)
0 commit comments