JIT: Preserve vector division exceptions during VN - #133912
dhartglassMSFT wants to merge 1 commit into
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
🔵 Needs a closer look
Unsigned vector-division coverage and a nearby exception-contract comment still need updates; the project entry also needs reordering.
Pull request overview
Fixes #133844 by preserving xarch vector integer-division exception behavior during JIT value numbering.
Changes:
- Models divide-by-zero and signed overflow exceptions for vector division.
- Adds regression coverage for divide-by-zero and overflow.
- Registers the new regression test.
File summaries
| File | Summary | Final review findings |
|---|---|---|
src/tests/JIT/Regression/Regression_o_2.csproj |
Registers the regression test. | Nit (1 vote): Move Runtime_133844 into lexicographic order between Runtime_133209 and Runtime_13417. |
src/tests/JIT/Regression/JitBlue/Runtime_133844/Runtime_133844.cs |
Tests preserved vector division exceptions. | None. |
src/coreclr/jit/valuenum.cpp |
Models vector division exceptions during value numbering. | Moderate (1 vote): Add optimized Vector<uint> divide-by-zero coverage. Nit (1 vote): Update the nearby comment so it does not incorrectly describe the vector division exception contract. |
Review details
Suppressed comments (3)
src/coreclr/jit/valuenum.cpp:14336
- The comment immediately below this block (around line 14359) still says these intrinsics can only throw
NullReferenceException, but this block now addsDivideByZeroExceptionandArithmeticExceptionto the VN exception set for vector division. Please narrow that comment to the memory-load/store case or otherwise update it so it does not describe an incorrect exception contract.
}
src/coreclr/jit/valuenum.cpp:14334
- The new
varTypeIsSignedsplit leaves the unsigned vector-division path untested: this regression only usesVector<int>, and the existing generic divide-by-zero tests cover signed types but omituint. Since this branch intentionally excludesVNF_ArithmeticExcforVector<uint>while still adding the divide-by-zero exception, add an optimizedVector<uint>divide-by-zero case so regressions in the unsigned behavior are caught.
if (varTypeIsSigned(tree->GetSimdBaseType()))
{
ValueNumPair arithmeticExc = vnStore->VNPExcSetSingleton(
vnStore->VNPairForFuncNoFolding(TYP_REF, VNF_ArithmeticExc, dividendVNP, divisorVNP));
excSetPair = vnStore->VNPExcSetUnion(excSetPair, arithmeticExc);
src/tests/JIT/Regression/Regression_o_2.csproj:146
- This entry breaks the lexicographic order used by the surrounding
Compileitems:Runtime_133844should be betweenRuntime_133209andRuntime_13417, rather than afterRuntime_41100. Please move it into that position to preserve the project's deterministic ordering.
<Compile Include="JitBlue\Runtime_133844\Runtime_133844.cs" />
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
9aa1be2 to
efc545d
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Add unsigned-vector divide-by-zero regression coverage.
Review details
Suppressed comments (1)
src/tests/JIT/Regression_o_2/Runtime_133844.cs:29
- Please add an unsigned-vector divide-by-zero case alongside these signed tests. The production change intentionally has a separate signed/unsigned path at
valuenum.cpp:14330-14335, but the regression suite only instantiatesVector<int>, so a future regression inVector<uint>DivideByZeroExceptionpreservation would go undetected.
[Fact]
public static void OverflowIsPreserved()
{
Assert.Throws<OverflowException>(new Runtime_133844().Overflow);
}
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Can we re-use |
Value numbering for vector division must take exception behavior into account.
fixes #133844