<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
{font-family:"\@Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi All, <o:p></o:p></p><p class=MsoNormal>I found some cases where a spill of a live range in a block is reloaded only in one of its successors, and there is no reload in other paths through other successors. Since the spill is reloaded only in a certain path, it must be okay to sink such spill close to its reloads. In the AArch64 code below, there is a spill(x2) in the entry, but this value is reloaded only in %bb.1, not in .LBB2_32. If we sink the spill (str x2, [sp, #120]) from the entry to its successor (%bb.1), the load-from-store promotion might catch this and replace the ldr in %bb.1 with a mov instruction. As we move such spill down to its successor, we can also encourage more shrink-wrapping as well.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>.globl _mytest<o:p></o:p></p><p class=MsoNormal>// %bb.0: // %entry<o:p></o:p></p><p class=MsoNormal> sub sp, sp, #224 // =224<o:p></o:p></p><p class=MsoNormal> stp x28, x27, [sp, #128] // 8-byte Folded Spill<o:p></o:p></p><p class=MsoNormal> stp x26, x25, [sp, #144] // 8-byte Folded Spill<o:p></o:p></p><p class=MsoNormal> stp x24, x23, [sp, #160] // 8-byte Folded Spill<o:p></o:p></p><p class=MsoNormal> stp x22, x21, [sp, #176] // 8-byte Folded Spill<o:p></o:p></p><p class=MsoNormal> stp x20, x19, [sp, #192] // 8-byte Folded Spill<o:p></o:p></p><p class=MsoNormal> stp x29, x30, [sp, #208] // 8-byte Folded Spill<o:p></o:p></p><p class=MsoNormal> ldrsw x8, [x0, #4424]<o:p></o:p></p><p class=MsoNormal> sxtw x10, w2 <------------- w2 is the use of spilled value before spill.<o:p></o:p></p><p class=MsoNormal> sxtw x12, w1<o:p></o:p></p><p class=MsoNormal> madd x8, x8, x10, x12<o:p></o:p></p><p class=MsoNormal> ldr x9, [x0, #8]<o:p></o:p></p><p class=MsoNormal> add x9, x9, x8, lsl #2<o:p></o:p></p><p class=MsoNormal> ldrh w11, [x9]<o:p></o:p></p><p class=MsoNormal> ldrh w10, [x0, #16]<o:p></o:p></p><p class=MsoNormal> str x2, [sp, #120] // 8-byte Folded Spill <------------- spill !!! <o:p></o:p></p><p class=MsoNormal> cmp w11, w10<o:p></o:p></p><p class=MsoNormal> b.eq .LBB2_32<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>// %bb.1: // %if.end<o:p></o:p></p><p class=MsoNormal> ldr x13, [sp, #120] // 8-byte Folded Reload <-------------- reload !!<o:p></o:p></p><p class=MsoNormal> < omitted ><o:p></o:p></p><p class=MsoNormal> :<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>.LBB2_32: // %cleanup <----- no reload from [sp, #120]<o:p></o:p></p><p class=MsoNormal> ldp x29, x30, [sp, #208] // 8-byte Folded Reload<o:p></o:p></p><p class=MsoNormal> ldp x20, x19, [sp, #192] // 8-byte Folded Reload<o:p></o:p></p><p class=MsoNormal> ldp x22, x21, [sp, #176] // 8-byte Folded Reload<o:p></o:p></p><p class=MsoNormal> ldp x24, x23, [sp, #160] // 8-byte Folded Reload<o:p></o:p></p><p class=MsoNormal> ldp x26, x25, [sp, #144] // 8-byte Folded Reload<o:p></o:p></p><p class=MsoNormal> ldp x28, x27, [sp, #128] // 8-byte Folded Reload<o:p></o:p></p><p class=MsoNormal> add sp, sp, #224 // =224<o:p></o:p></p><p class=MsoNormal> ret<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Unless there is hidden issues that prevent it from being sunk, I think such sinking should be done after RA because sinking it down during RA will extend the live range of the spilled value. Please let me know if there any hidden issue that I miss here? I may happy to hear any opinion about it.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks, <o:p></o:p></p><p class=MsoNormal>Jun<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>