Skip to content

Commit 12e176d

Browse files
authored
Fix OperExceptions for SIMD Divide (#113394)
1 parent 6cfbc7d commit 12e176d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7124,15 +7124,27 @@ ExceptionSetFlags GenTree::OperExceptions(Compiler* comp)
71247124

71257125
GenTreeHWIntrinsic* hwIntrinsicNode = this->AsHWIntrinsic();
71267126

7127+
ExceptionSetFlags flags = ExceptionSetFlags::None;
71277128
if (hwIntrinsicNode->OperIsMemoryLoadOrStore())
71287129
{
71297130
// TODO-CQ: We should use comp->fgAddrCouldBeNull on the address operand
71307131
// to determine if this can actually produce an NRE or not
7132+
flags |= ExceptionSetFlags::NullReferenceException;
7133+
}
71317134

7132-
return ExceptionSetFlags::NullReferenceException;
7135+
#ifdef TARGET_XARCH
7136+
NamedIntrinsic intrinsicId = hwIntrinsicNode->GetHWIntrinsicId();
7137+
if ((intrinsicId == NI_Vector128_op_Division) || (intrinsicId == NI_Vector256_op_Division) ||
7138+
(intrinsicId == NI_Vector512_op_Division))
7139+
{
7140+
// We currently don't try to avoid setting these flags and GTF_EXCEPT when
7141+
// we know that the operation in fact cannot overflow/divide by zero.
7142+
assert(varTypeIsInt(AsHWIntrinsic()->GetSimdBaseType()));
7143+
flags |= ExceptionSetFlags::OverflowException | ExceptionSetFlags::DivideByZeroException;
71337144
}
7145+
#endif
71347146

7135-
return ExceptionSetFlags::None;
7147+
return flags;
71367148
}
71377149
#endif // FEATURE_HW_INTRINSICS
71387150

0 commit comments

Comments
 (0)