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: Refactor physical promotion store decomposition slightly #88182

Merged

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Jun 29, 2023

Introduce a LocationAccess helper class to create derived accesses off of the destination and source locations for the store. Unify all the code that looks for regularly promoted fields in this class, and use it consistently for all the derived accesses.

Also update terminology from "assignment" to "store" in a few places, and add a "(last use)" string for fields when decomposing block inits.

Precursor to #88109.

Introduce a LocationAccess helper class to create derived accesses off
of the destination and source locations for the store. Unify all the
code that looks for regularly promoted fields in this class, and use it
consistently for all the derived accesses.

Also update terminology from "assignment" to "store" in a few places,
and add a "(last use)" string for fields when decomposing block stores.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 29, 2023
@ghost ghost assigned jakobbotsch Jun 29, 2023
@ghost
Copy link

ghost commented Jun 29, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Introduce a LocationAccess helper class to create derived accesses off of the destination and source locations for the store. Unify all the code that looks for regularly promoted fields in this class, and use it consistently for all the derived accesses.

Also update terminology from "assignment" to "store" in a few places, and add a "(last use)" string for fields when decomposing block stores.

Precursor to #88109.

Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch jakobbotsch marked this pull request as ready for review June 29, 2023 19:34
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @EgorBo

Some very minor diffs. They occur because of the change to no longer keep regular promoted locals in the decomposition plan, and instead handle that when we get to the corresponding field offset (inside LocationAccess). That sometimes allows some other optimizations in store decomposition to kick in. Example:

 STMT00002 ( 0x00F[E-] ... ??? )
                [000008] DAC--------                         ▌  STORE_LCL_VAR struct<System.DateTimeOffset, 16> V02 loc0         
                [000006] --C-G------                         └──▌  CALL      struct System.DateTimeOffset:get_UtcNow():System.DateTimeOffset
 Processing block operation [000008] that involves replacements
 Fields of [000008] in range [000..016) need to be read back: cannot decompose store
   V66 (V02.[000..002)) marked
   V67 (V02.[008..016)) marked
 STMT00027 ( 0x015[E-] ... ??? )
                [000095] DA---------                         ▌  STORE_LCL_VAR struct<System.DateTimeOffset, 16>(P) V06 tmp3         
                                                             ▌    short  field V06._offsetMinutes (fldOffset=0x0) -> V38 tmp35         (last use)
                                                             ▌    long   field V06._dateTime (fldOffset=0x8) -> V39 tmp36        
                [000009] -----------                         └──▌  LCL_VAR   struct<System.DateTimeOffset, 16> V02 loc0         
 Processing block operation [000095] that involves replacements
   Source replacement V66 (V02.[000..002)) is stale. Will read it back before copy.
-  V38 (field V06._offsetMinutes (fldOffset=0x0)) <- V66 (V02.[000..002))
+  dst+000 <- V66 (V02.[000..002))
   Source replacement V67 (V02.[008..016)) is stale. Will read it back before copy.
-  V39 (field V06._dateTime (fldOffset=0x8)) <- V67 (V02.[008..016))
+  dst+008 <- V67 (V02.[008..016))
   Block op remainder: [002..008)
   => Remainder strategy: retain a full block op
+  Skipping dst+000 <- V66 (V02.[000..002)); it is up-to-date in its struct local and will be handled as part of the remainder
+  Skipping dst+008 <- V67 (V02.[008..016)); it is up-to-date in its struct local and will be handled as part of the remainder
 New statement:
 STMT00027 ( 0x015[E-] ... ??? )
-               [000345] -A---------                         ▌  COMMA     void  
+               [000339] -A---------                         ▌  COMMA     void  
                [000335] DA---------                         ├──▌  STORE_LCL_VAR int    V66 tmp63        
                [000334] -----------                         │  └──▌  LCL_FLD   short  V02 loc0         [+0]
-               [000344] -A---------                         └──▌  COMMA     void  
+               [000338] -A---------                         └──▌  COMMA     void  
                [000337] DA---------                            ├──▌  STORE_LCL_VAR long   V67 tmp64        
                [000336] -----------                            │  └──▌  LCL_FLD   long   V02 loc0         [+8]
-               [000343] -A---------                            └──▌  COMMA     void  
-               [000095] DA---------                               ├──▌  STORE_LCL_VAR struct<System.DateTimeOffset, 16>(P) V06 tmp3         
-                                                                  ├──▌    short  field V06._offsetMinutes (fldOffset=0x0) -> V38 tmp35         (last use)
-                                                                  ├──▌    long   field V06._dateTime (fldOffset=0x8) -> V39 tmp36        
-               [000009] -----------                               │  └──▌  LCL_VAR   struct<System.DateTimeOffset, 16> V02 loc0         
-               [000342] -A---------                               └──▌  COMMA     void  
-               [000339] DA---------                                  ├──▌  STORE_LCL_VAR short  V38 tmp35        
-               [000338] -----------                                  │  └──▌  LCL_VAR   short  V66 tmp63        
-               [000341] DA---------                                  └──▌  STORE_LCL_VAR long   V39 tmp36        
-               [000340] -----------                                     └──▌  LCL_VAR   long   V67 tmp64        
+               [000095] DA---------                            └──▌  STORE_LCL_VAR struct<System.DateTimeOffset, 16>(P) V06 tmp3         
+                                                                  ▌    short  field V06._offsetMinutes (fldOffset=0x0) -> V38 tmp35         (last use)
+                                                                  ▌    long   field V06._dateTime (fldOffset=0x8) -> V39 tmp36        
+               [000009] -----------                               └──▌  LCL_VAR   struct<System.DateTimeOffset, 16> V02 loc0         

(On a side note: the EE is telling us here that padding of DateTimeOffset is significant, which seems incorrect. Probably related to auto layout types.)

@jakobbotsch
Copy link
Member Author

Realized there was a bit more to clean up so pushed another commit.

{
if (genTypeSize(type) == 1)
{
return m_indirFlags & ~GTF_IND_UNALIGNED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to be done inside gtNewIndir itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, creating these derived indirections probably doesn't happen in any other place than decomposition and block morph. And even if it does we probably don't even need to remove this flag... I'm just being overly cautious here.

Copy link
Member

@EgorBo EgorBo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, is "assignment" now a prohibited terminology? 🙂

@jakobbotsch
Copy link
Member Author

LGTM, is "assignment" now a prohibited terminology? 🙂

I wouldn't call it prohibited, but seems nice to be consistent. I'm still writing "assignment decomposition" half the time I refer to this part of physical promotion ☹️

@jakobbotsch jakobbotsch merged commit 4f66e3c into dotnet:main Jun 30, 2023
122 of 125 checks passed
@jakobbotsch jakobbotsch deleted the physical-promotion-refactor-store-decomp branch June 30, 2023 12:50
jakobbotsch added a commit to jakobbotsch/runtime that referenced this pull request Jun 30, 2023
…#88182)

Introduce a LocationAccess helper class to create derived accesses off
of the destination and source locations for the store. Unify all the
code that looks for regularly promoted fields in this class, and use it
consistently for all the derived accesses.

Also update terminology from "assignment" to "store" in a few places,
and add a "(last use)" string for fields when decomposing block stores.
jakobbotsch added a commit to jakobbotsch/runtime that referenced this pull request Jun 30, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 30, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants