Skip to content

JIT: heuristics in optInvertWhileLoop may be overly conservative #6569

Closed

Description

@JosephTremoulet

For example, the loop in method Fit from benchmark Puzzle gets rejected as too costly, causing loop hoisting etc. not to run on it, but it's a good candidate for such optimizations and Jit64 performed them on it:

    private bool Fit(int i, int j)
    {
        for (int k = 0; k <= _pieceMax[i]; k++)
        {
            if (_p[i][k])
            {
                if (_puzzle[j + k])
                {
                    return false;
                }
            }
        }

        return true;
    }

There's already special consideration for loop conditions that involve shared static helpers; maybe similar treatment should be applied to loop conditions involving arrLen operators.

In this particular case, getting past the heuristic would enable hoisting the load of _p and the sign extension of i from the loop, but hoisting more of _p[i] (like the length of _p, the bounds-check, and/or the whole load) is blocked by #6554.

category:cq
theme:loop-opt
skill-level:expert
cost:medium

Activity

  1. transferred this issue fromdotnet/coreclron Jan 31, 2020
  2. added this to the Future milestone on Jan 31, 2020
  3. AndyAyersMS commented on Jul 7, 2020

    @AndyAyersMS
    Member

    See also notes/prototype in #780. Tried extending the cloning to cover multiple statements, etc.

  4. added
    JitUntriaged
    on Oct 28, 2020
  5. modified the milestones: Future, 6.0.0 on Jan 15, 2021
  6. removed
    JitUntriaged
    on Jan 15, 2021
  7. added
    needs-further-triage
    on Mar 23, 2021
  8. changed the title [-]JIT: heuristics in fgOptWhileLoop may be overly conservative[/-] [+]JIT: heuristics in optInvertWhileLoop may be overly conservative[/+] on Mar 30, 2021
  9. added and removed
    needs-further-triage
    on Apr 6, 2021
  10. BruceForstall commented on Apr 24, 2021

    @BruceForstall
    Contributor

    This was fixed by #50982

  11. ghost locked as resolved and limited conversation to collaborators on May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrenhancementoptimizationtenet-performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions