Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Loop hoisting is overly-conservative with helper calls #6553

Closed
JosephTremoulet opened this issue Aug 24, 2016 · 0 comments
Closed

JIT: Loop hoisting is overly-conservative with helper calls #6553

JosephTremoulet opened this issue Aug 24, 2016 · 0 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization
Milestone

Comments

@JosephTremoulet
Copy link
Contributor

Loop hoisting has code to avoid illegally re-ordering side-effects, which includes a check for calls that is overly-general. The check looks at the GTF_CALL flag, which (A) will be set for the entire expression containing a call as a sub-expression (which is unnecessary because this code is walking the whole tree), and (B) doesn't distinguish non-side-effecting helper calls, like we do in value-numbering and in the code just above that identifies hoistable calls. This blocks hoisting of the m_arr accesses (because of the GetStaticBase helper call that precedes them) in the following code, even with a fix for #6552 in place:

using System;
using System.Diagnostics;

class ArrayPerf
{

    private static int[] m_arr;
    private const int MAX_ARRAY_SIZE = 4096;

    private static readonly int DIM_1 = MAX_ARRAY_SIZE;

    static void Main(string[] args)
    {
        long iterations = Int64.Parse(args[0]);

        int value;
        m_arr = new int[DIM_1];

        for (int i = 0; i < DIM_1; i++)
            m_arr[i] = i;

        for (int j = 0; j < DIM_1; j++)
            value = m_arr[j];

        //var sw = Stopwatch.StartNew();

        for (long i = 0; i < iterations; i++)
        {
            for (int j = 0; j < DIM_1; j++)
            {
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
                value = m_arr[j];
            }
        }

        //sw.Stop();
        //Console.WriteLine(sw.ElapsedMilliseconds);
    }
}
JosephTremoulet referenced this issue in JosephTremoulet/coreclr Sep 1, 2016
Update the code in `optHoistLoopExprsForTree` that identifies exprs with
memory side-effects to recognize helper calls that don't mutate the heap;
this allows hoisting invariant exprs past such helper calls.

Fixes #6901.
JosephTremoulet referenced this issue in JosephTremoulet/coreclr Sep 1, 2016
Update the code in `optHoistLoopExprsForTree` that identifies exprs with
memory side-effects to recognize helper calls that don't mutate the heap;
this allows hoisting invariant exprs past such helper calls.

Fixes #6901.
JosephTremoulet referenced this issue in JosephTremoulet/coreclr Sep 13, 2016
Update the code in `optHoistLoopExprsForTree` that identifies exprs with
memory side-effects to recognize helper calls that don't mutate the heap;
this allows hoisting invariant exprs past such helper calls.

Fixes #6901.
JosephTremoulet referenced this issue in JosephTremoulet/coreclr Sep 14, 2016
Update the code in `optHoistLoopExprsForTree` that identifies exprs with
memory side-effects to recognize helper calls that don't mutate the heap;
this allows hoisting invariant exprs past such helper calls.

Fixes #6901.
JosephTremoulet referenced this issue in JosephTremoulet/coreclr Sep 14, 2016
Update the code in `optHoistLoopExprsForTree` that identifies exprs with
memory side-effects to recognize helper calls that don't mutate the heap;
this allows hoisting invariant exprs past such helper calls.

Fixes #6901.
JosephTremoulet referenced this issue in JosephTremoulet/coreclr Sep 15, 2016
Update the code in `optHoistLoopExprsForTree` that identifies exprs with
memory side-effects to recognize helper calls that don't mutate the heap;
this allows hoisting invariant exprs past such helper calls.

Fixes #6901.
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization
Projects
None yet
Development

No branches or pull requests

2 participants