Skip to content

JIT: morph late canonicalization of assign foils local assertion prop #12098

Closed

Description

@AndyAyersMS

Morph propagates assertions before morphing, and assertion prop doesn't handle copy assertions for copies with sources in obj(addr(lcl)) form. Morph then transforms some of these into simple copies:

In BB01 New Local Copy     Assertion: V02 == V01 index=#02, mask=0000000000000002
....      
fgMorphTree BB01, stmt 9 (before)
               [000025] n-----------              /--*  OBJ(24)   struct
               [000024] ------------              |  \--*  ADDR      byref 
               [000023] ------------              |     \--*  LCL_VAR   struct V02 tmp2         
               [000081] -A----------              *  ASG       struct (copy)
               [000079] D-----------              \--*  LCL_VAR   struct V04 tmp4         
...
fgMorphTree BB01, stmt 9 (after)
               [000023] -----+-N----              /--*  LCL_VAR   struct V02 tmp2         
               [000081] -A---+------              *  ASG       struct (copy)
               [000079] D----+-N----              \--*  LCL_VAR   struct V04 tmp4         

If we re-ran assertion prop at this point we'd change the source to tmp1 and quite possibly avoid a struct copy.

Perhaps it makes sense to either retry assertion prop after morphing (at least for this case), or work harder to produce the simple struct copy forms upstream. One common source of these is inlining args....

cc @dotnet/jit-contrib

category:cq
theme:morph
skill-level:expert
cost:medium

Activity

  1. mikedn commented on Feb 22, 2019

    @mikedn
    Contributor

    or work harder to produce the simple struct copy forms upstream

    I've experienced a similar situation with struct promotion - apparently doing it before morphing, in LocalAddressVisitor also unblocks copy assertion propagation in some cases. Though in your specific case it looks like we should just produce the "right" IR in the importer, using OBJ(ADDR(LCL_VAR)) is probably another leftover from GT_COPYBLK days. For local variables OBJ should only be needed when struct-typed local fields are involved.

  2. AndyAyersMS commented on Feb 22, 2019

    @AndyAyersMS
    MemberAuthor

    Also optCopyProp_LclVarScore probably needs some tweaking...

  3. transferred this issue fromdotnet/coreclron Jan 31, 2020
  4. added this to the Future milestone on Jan 31, 2020
  5. added
    JitUntriaged
    on Oct 28, 2020
  6. removed
    JitUntriaged
    on Nov 26, 2020
  7. AndyAyersMS commented on Aug 26, 2022

    @AndyAyersMS
    MemberAuthor

    Seems like this will largely be addressed by #74384

  8. ghost locked as resolved and limited conversation to collaborators on Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions