<div dir="auto"><div style="font-family:sans-serif;font-size:13.696px" dir="auto"><div style="margin:16px 0px"><div><div><div><p>Hi<u></u><u></u></p><p><u></u> <u></u></p><p>I have a code pattern like this:<u></u><u></u></p><p><u></u> <u></u></p><p>Load value 1 from mem<u></u><u></u></p><p>Load value 2  from mem<u></u><u></u></p><p><u></u> <u></u></p><p>For (…) {<u></u><u></u></p><p>  Use value 2<u></u><u></u></p><p>  Use value 1<u></u><u></u></p><p>}<u></u><u></u></p><p><u></u> <u></u></p><p>During register allocations values loaded are spilled and I end up with this pattern:<u></u><u></u></p><p><u></u> <u></u></p><p>Load value 1 from mem<u></u><u></u></p><p>Store value 1 to stack<u></u><u></u></p><p>Load value 2  from mem<u></u><u></u></p><p>Store value 2 to stack<u></u><u></u></p><p><u></u> <u></u></p><p>For (…) {<u></u><u></u></p><p>  Load value 2 from stack<u></u><u></u></p><p>  Use value 2<u></u><u></u></p><p>  Load value 1 from stack<u></u><u></u></p><p>  Use value 1<u></u><u></u></p><p>}<u></u><u></u></p><p><u></u> <u></u></p><p>At least for my case, I prefer to load directly from memory inside the loop. From what I have heard, this is a known issue with the register allocator. I have a few questions:<u></u><u></u></p><p><u></u> <u></u></p><p style="margin:0in 0in 0.0001pt 0.5in;font-size:11pt;font-family:'calibri',sans-serif"><u></u>1-<span style="font-stretch:normal;font-size:7pt;line-height:normal;font-family:"times new roman"">      </span><u></u>Has there been any attempt to fix this? If yes, what was the experience when dealing with tradeoffs (for example if value 1 and value 2 are far apart in memory and loop trip count is high, the current codegen might be better)<u></u><u></u></p><p style="margin:0in 0in 0.0001pt 0.5in;font-size:11pt;font-family:'calibri',sans-serif"><br></p><p style="margin:0in 0in 0.0001pt 0.5in;font-size:11pt;font-family:'calibri',sans-serif"><u></u>2-<span style="font-stretch:normal;font-size:7pt;line-height:normal;font-family:"times new roman"">      </span><u></u>If I want to experiment with some fixes for this, where in the register allocator code I should look?<u></u><u></u></p><p><u></u> <u></u></p><p>Thanks<font color="#888888"><u></u><u></u></font></p><font color="#888888"><p>Ehsan<u></u><u></u></p><p><u></u> <u></u></p><p><u></u><u></u></p></font></div></div></div></div><div style="height:0px"></div></div><div style="font-family:sans-serif;font-size:13.696px" dir="auto"><br></div></div>