<html><head><base href="x-msg://1781/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 23, 2012, at 5:11 PM, Zino Benaissa wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Optima; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div lang="EN-US" link="blue" vlink="purple"><div class="WordSection1" style="page: WordSection1; "><div style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; margin-top: 0in; margin-bottom: 0.0001pt; "><b>Description:<o:p></o:p></b></div><div style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; margin-top: 0in; margin-bottom: 0.0001pt; ">This contribution extends LLVM greedy Register Allocator to optimize for code size when LLVM compiler targets ARM Thumb 2 instruction set. This heuristic favors<b><i><span style="color: rgb(31, 73, 125); "><span class="Apple-converted-space"> </span></span></i></b>assigning register R0 through R7 to operands used in instruction that can be encoded in 16 bits (16-bit is allowed only if R0-7 are used). Operands that appear most frequently in a function (and in instructions that qualify) get R0-7 register.<o:p></o:p></div><div style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; margin-top: 0in; margin-bottom: 0.0001pt; ">This heuristic is turned on by default and has impact on generated code only if -mthumb compiler switch is used. To turn this heuristic off use -disable-favor-r0-7 feature flag.<o:p></o:p></div><div style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; margin-top: 0in; margin-bottom: 0.0001pt; "><o:p> </o:p></div><div style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; margin-top: 0in; margin-bottom: 0.0001pt; ">This patch modifies:<span class="Apple-converted-space"> </span><br>1) The LLVM greedy register allocator located in LLVM/CodeGen directory: To add the new code size heuristic.<br>2) The ARM-specific flies located in LLVM/Target/ARM directory: To add the function that determines<span style="color: rgb(31, 73, 125); "><span class="Apple-converted-space"> </span></span>which instruction can be encoded in 16-bits and a fix to enable the compiler to emit CMN instruction in 16-bits encoding.<span class="Apple-converted-space"> </span><br>3) The LLVM test suite: fix test/CodeGen/Thumb2/thumb2-cmn.ll test.</div></div></div></span></blockquote><div><br></div><div>Hi Zino,</div><div><br></div><div>Thanks for working on this interesting patch.</div><div><br></div><div>Please submit the CMN-related changes as an independent patch.</div><div><br></div><div>If you don't mind, I would like you to run a couple of experiments to better understand why this change improves some benchmarks.</div><div><br></div><div>First of all, is the regHasSizeImpact() hook necessary? Do you get significantly different results if you pretend this function always returns 2?</div><div><br></div><div>Second, what happens if you use a 'flatter' spill weight? Instead of your patch, in LiveIntervals::getSpillWeight replace this:</div><div><br></div><div><div>  float lc = std::pow(1 + (100.0 / (loopDepth + 10)), (double)loopDepth);</div><div><br></div><div>with this:</div><div><br></div></div><div><div>  float lc = std::pow(1 + (100.0 / (loopDepth + 10))/5, (double)loopDepth);</div><div><br></div><div>And in CalcSpillWeights.h, replace the number 25 in normalizeSpillWeight() with 250. Does that give you similar results?</div><div><br></div><div>Thanks,</div><div>/jakob</div><div><br></div></div></div></body></html>