Skip to content

SIMD problems when mixing llvm and non-llvm code #73454

@vargaz

Description

@vargaz

Description

Currently on mono, SIMD is only supported when using LLVM compiled code. This can lead to various problems when mixing llvm and non-llvm compiled code. This mixing can happen for various reasons:

  • profiled AOT
  • LLVM doesn't support some IL constructs like filter clauses
  1. Different calling conventions
    LLVM code passes SIMD types in SIMD registers, while JITted code passes them on the stack.
    Testcase:
using System;
using System.Numerics;

public class Tests
{
    public static void Main () {
        foo (new Vector<int> (1));
    }

    static void foo (Vector<int> v) {
        try {
            Console.WriteLine (v);
        } catch (Exception ex) when (ex is OverflowException) {
            }
    }
}
  1. The IsSupported methods return different values in LLVM and non-LLVM methods, leading to subtle logic problems:
using System;
using System.Numerics;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;

public class Tests
{
    public static void Main () {
        if (AdvSimd.Arm64.IsSupported)
            foo (new Vector128<double> ());
    }

    static void foo (Vector128<double> v) {
        try {
        } catch (Exception ex) when (ex is OverflowException) {
            }
        AdvSimd.Arm64.Abs (v);
    }
}

This will fail when AOT-ed using --aot=llvm

Reproduction Steps

.

Expected behavior

.

Actual behavior

.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions