') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); JIT: Refactor physical promotion store decomposition slightly by jakobbotsch · Pull Request #88182 · dotnet/runtime · GitHub
Skip to content

JIT: Refactor physical promotion store decomposition slightly - #88182

Merged
jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:physical-promotion-refactor-store-decomp
Jun 30, 2023
Merged

JIT: Refactor physical promotion store decomposition slightly#88182
jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:physical-promotion-refactor-store-decomp

Conversation

@jakobbotsch

@jakobbotschjakobbotsch commented Jun 29, 2023

Copy link
Copy Markdown
Member

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.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 29, 2023
@ghost

Copy link
Copy Markdown

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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.

@EgorBoEgorBo left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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:mainJun 30, 2023
@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
@ghostghost locked as resolved and limited conversation to collaborators Jul 30, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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

@jakobbotsch@EgorBo