Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HwiSideEffects.cs « HwiOp « General « HardwareIntrinsics « JIT « tests « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 932a8d857fdcf1345ac368b189706fc2d6d9740b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using System.Runtime.CompilerServices;
using Xunit;

// Tests that side effects induced by the HWI nodes are correctly accounted for.

unsafe class HwiSideEffects
{
    [Fact]
    public static void TestProblemWithInterferenceChecks()
    {
        Assert.Equal((uint)2, ProblemWithInterferenceChecks(2));
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static uint ProblemWithInterferenceChecks(uint a)
    {
        uint x;
        if (Bmi2.IsSupported)
        {
            // Make sure we don't try to contain "a" under the "add" here.
            x = a + Bmi2.MultiplyNoFlags(a, a, &a);
        }
        else
        {
            x = a;
        }

        return x;
    }

    [Fact]
    public static void TestProblemWithThrowingLoads()
    {
        Assert.True(ProblemWithThrowingLoads(null));
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private static bool ProblemWithThrowingLoads(int* a)
    {
        bool result = false;
        try
        {
            Vector128.Load(a);
        }
        catch (NullReferenceException)
        {
            result = true;
        }

        return result;
    }
}