Skip to content

[clr-interp] Matrix4x4 tests fail on DOTNET_InterpMode=1 #123104

Closed

Description

@davidwrighton

On DOTNET_InterpMode=1 these tests fail because the underlying SIMD api uses Single.MultiplyAddEstimate which behaves differently than the expected path when jitted vs R2R'd

Activity

  1. added
    untriaged
    on Jan 12, 2026
  2. davidwrighton commented on Jan 12, 2026

    @davidwrighton
    MemberAuthor

    I don't think we should fix this.

  3. dotnet-policy-service commented on Jan 12, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
    See info in area-owners.md if you want to be subscribed.

  4. tannergooding commented on Jan 12, 2026

    @tannergooding
    Member

    The R2R path should be marking these appropriately, so they are forced to compile at runtime. We generally document this under https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/vectors-and-intrinsics.md#non-deterministic-intrinsics-in-systemprivatecorelib

    See also https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/importercalls.cpp#L9850-L9867, which should be hitting:

        if (BlockNonDeterministicIntrinsics(mustExpand))
        {
            return nullptr;
        }

    This in turn is implemented as:

        bool BlockNonDeterministicIntrinsics(bool mustExpand)
        {
            // We explicitly block these APIs from being expanded in R2R
            // since we know they are non-deterministic across hardware
    
            if (IsReadyToRun())
            {
                if (mustExpand)
                {
                    implLimitation();
                }
                return true;
            }
            return false;
        }

    That is, they should explicitly be left in as calls and not generated in the R2R image. Instead, they should end up always being jitted and so should always return the same result at runtime.

  5. BrzVlad commented on Jan 20, 2026

    @BrzVlad
    Member

    @tannergooding In our case, on ios, it would mean that these would be interpreted (so their execution would be orders of magnitude slower). Would you say that this is acceptable ? Do you think these would be performance critical ?

  6. tannergooding commented on Jan 20, 2026

    @tannergooding
    Member

    In our case, on ios, it would mean that these would be interpreted (so their execution would be orders of magnitude slower). Would you say that this is acceptable ?

    I think its a matter of correctness and so a bit irrelevant. We cannot have functions, particularly "core math" functions differing in result between different modes (AOT vs R2R vs JIT vs Interpreter) within the same process.

    Do you think these would be performance critical ?

    The estimate functions primarily exist for "performance" related reasons. That is, they intentionally exist to say give me the faster of FusedMultiplyAdd(x, y, z) or (x * y) + z. I wouldn't think it should be terribly difficult for the interpreter to handle these itself. That being said, I also wouldn't expect them to be all that typical in code that ends up being interpreted in practice.

  7. BrzVlad commented on Jan 20, 2026

    @BrzVlad
    Member

    Thanks for the explanation. Seems like this issue reproduces on our tests due to misconfiguration. On iOS we should be fine since we would only use the interpreter path and it doesn't seem to be perf critical as of right now. Triaging as future milestone.

  8. removed
    untriaged
    on Jan 20, 2026
  9. added this to the Future milestone on Jan 20, 2026
  10. AndyAyersMS commented on Jul 31, 2026

    @AndyAyersMS
    Member

    I ran into this same failure in #131493. Looks like it may be an interpreter bug?

    AI analysis:

    InterpCompiler::AllocOffsets  ( src/coreclr/interpreter/compileropt.cpp ) marked a  dVar 's destination call "active" after calling  EndActiveCall(pIns). So a call whose result feeds another call's arguments never became a dependency of that call, and both got base offset 0 in the param area. The inner call's return buffer therefore aliased its own arguments:

    IR_0049: call [288 <- 288] Vector3:op_UnaryNegation
    IR_004d: call [288 <- 288] Matrix4x4:CreateTranslation(Vector3) <-- corrupts position
    IR_006a: call [288 <- 288] Matrix4x4:op_Multiply

     Matrix4x4.CreateTranslation  writes  result.X/Y/Z  into the retbuf, clobbering  position  (bytes 0–11), then reads  position  back for  result.W  →  W = (1,0,0,1)  instead of the translation row.  clr-abi.md:143  explicitly permits a compiled callee to use the return buffer as scratch, so the interpreter is at fault. It only manifests with an R2R/JIT'd callee — an interpreted callee copies to the retbuf only at  ret .

    (As noted this only shows up with R2R because of different timing in when the retbuf is written).

    I'll put up a PR with a proposed fix.

  11. added a commit that references this issue on Aug 5, 2026
    62093b5
  12. modified the milestones: Future, 11.0.0 on Aug 6, 2026
  13. locked and limited conversation to collaborators on Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions