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

Optimize multi-dimensional array access #70271

Merged

Commits on Jul 1, 2022

  1. Multi-dimensional array cleanups

    1. Remove unused `gtArrElemType` member from GenTreeArrIndex, GenTreeArrOffs
    2. Add function iheader documentation for `impArrayAccessIntrinsic`
    3. Add JITDUMP output reasons for rejecting MD intrinsics in `impArrayAccessIntrinsic`
    
    No diffs
    BruceForstall committed Jul 1, 2022
    Configuration menu
    Copy the full SHA
    a869ba4 View commit details
    Browse the repository at this point in the history
  2. Fix GT_ARR_LENGTH to use TYP_BYREF, not TYP_REF

    This doesn't lead to any asm diffs because it was always contained.
    However, we BYREF is the correct type, since we've added to the
    array object base.
    BruceForstall committed Jul 1, 2022
    Configuration menu
    Copy the full SHA
    46f1397 View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2022

  1. Implement GT_MDARR_LENGTH

    It still needs support in ValueNumber, RangeCheck, CSE, RangeProp.
    
    No diffs.
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    d0fb518 View commit details
    Browse the repository at this point in the history
  2. Implement GT_MDARR_LOWER_BOUND

    No asm diffs
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    bbd89d0 View commit details
    Browse the repository at this point in the history
  3. Implement xarch codegen for GT_MDARR_LENGTH, GT_MDARR_LOWER_BOUND

    Add skeleton for MD array ops morphing.
    
    No diffs
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    6e1bcc2 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6c80b2c View commit details
    Browse the repository at this point in the history
  5. Implement early morphing of multi-dimensional array expressions

    Also,
    1. Convert dim/rank types to `unsigned`
    2. Assume type of GT_MDARR_LENGTH, GT_MDARR_LOWER_BOUND are TYP_INT
    3. Fix: add GT_MDARR_LOWER_BOUND to GenTree::VisitOperands
    4. Add dump of GT_MDARR_LENGTH, GT_MDARR_LOWER_BOUND `dim` field to tree dumps (required to distinguish them)
    5. Change impArrayAccessIntrinsic() to cast index types to TYP_INT but only under `compJitEarlyExpandMDArrays` to avoid asm diffs.
    6. Temporary: create new, unique value numbers for GT_MDARR_LENGTH, GT_MDARR_LOWER_BOUND; otherwise, they get optimized incorrectly by not looking at dimension value.
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    1c619ad View commit details
    Browse the repository at this point in the history
  6. Fix two bugs:

    1. Check for root opts.compJitEarlyExpandMDArrays flag, not in inlinee Compiler
    2. Fix order of evaluation for index expressions; copy index expressions with
    side effects.
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    53dc58b View commit details
    Browse the repository at this point in the history
  7. Various fixes/improvements

    - Change assert that index type is TYP_INT to check genActualType instead of type.
    - Change order of evaluation so array is evaluated first, before index expressions.
    - Only morph MD array ops if the function and block have them.
    - Remove unused `BBF_HAS_NEWARRAY`, add `BBF_HAS_MD_IDX_LEN`, `BBF_HAS_MDARRAYREF`
    - Add `OMF_HAS_MDNEWARRAY, `OMF_HAS_MDARRAYREF`
    - Add asserts that GT_ARR_ELEM doesn't exist by lowering if we're doing early lowering of MD arrays
    - Remove unneeded `ARR_ST_POST_VERIFY`, `ARR_LD_POST_VERIFY`
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    e816b6a View commit details
    Browse the repository at this point in the history
  8. Remove unnecessary lowering/codegen

    SimpleLowering is lowering MDARR_LEN, MD_ARR_LOWER_BOUND
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    5d0e1e5 View commit details
    Browse the repository at this point in the history
  9. Implement value numbering for GT_MDARR_LENGTH, GT_MDARR_LOWER_BOUND

    New CSEs and hoisted expressions are seen.
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    e058789 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    7ad712a View commit details
    Browse the repository at this point in the history
  11. Replace GenTreeArrLen, GenTreeArrLowerBound with GenTreeMDArr

    Introduce GenTreeArrCommon as parent of GenTreeArrLen, GenTreeMDArr.
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    4198176 View commit details
    Browse the repository at this point in the history
  12. Enable early MD array expansion

    Configuration variables:
    1. `COMPlus_JitEarlyExpandMDArrays`. Set to zero to disable early MD expansion. Default is 1 (enabled).
    2. If `COMPlus_JitEarlyExpandMDArrays=0`, use `COMPlus_JitEarlyExpandMDArraysFilter` to selectively
    enable early MD expansion for a method set (e.g., syntax like `JitDump`)
    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    39de3ae View commit details
    Browse the repository at this point in the history
  13. Add comments

    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    40019df View commit details
    Browse the repository at this point in the history
  14. Formatting

    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    92c73fe View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    7a14656 View commit details
    Browse the repository at this point in the history
  16. Fix build/merge

    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    a0d0812 View commit details
    Browse the repository at this point in the history
  17. Comments

    BruceForstall committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    0f7836c View commit details
    Browse the repository at this point in the history