summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Regression/JitBlue/DevDiv_278365/DevDiv_278365.cs
blob: 631175a38e79a741b8bf87b8509be570cd680391 (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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.


using System;
using System.Runtime.CompilerServices;

// This test is a reduced repro case for DevDiv VSO bug 278365.
// The failure mode is that the RyuJIT/x86 backend changed call to ROUND intrinsic
// with double return type to ROUND intrinsic with int return type, that is not supported.

internal class Program
{
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static int Bar()
    {
        int sum = 0;
        for (int i = 0; i < 100; ++i)
        {
            int v = (int)Math.Round(4.4 + i);
            sum += v;
        }
        sum -= 4 * 100;
        if (sum != 100 * 99 / 2)
        {
            return 0;
        }
        else
        {
            return 100;
        }        
    }
	
    private static int Main(string[] args)
    {
        try
        {
            if (Bar() != 100)
                return 0;
        }
        catch (Exception)
        {
        }

        Console.WriteLine("Pass");
        return 100;
    }
}