<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 25, 2014 at 7:11 PM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>What allocation means here (on a second thought that is not super clear) is the number of ports an instruction uses.</div>
</blockquote><div><br></div><div>This is a fine explanation. =] It would be good to put it into the x86 implementation of getScalingFactor, maybe with examples?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br></div><div>Regarding the benchmarks, the numbers are unchanged on the llvm test suite + specs.</div><div><br></div><div>In fact, this commit is just the first step toward performance improvements. Indeed, this hook is not yet sufficient to make LSR to prefer the addressing mode of the form 'reg'  compared to those of the form 'reg1 + reg2 * scale'.</div>
<div>Indeed, currently we still prefer 'reg1 + reg2 * scale' to 'reg', in many cases and in particular with scale = 1, which is wrong performance wise. I am working on fixing this.</div></blockquote><div><br>
</div><div>Makes sense.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>With my current prototype, I see up to 30% speed up on small kernels.</div>
</blockquote></div><div class="gmail_extra"><br></div>Cool.</div><div class="gmail_extra"><br></div><div class="gmail_extra">My only concern are the cases where not doing the scale requires more instructions. In particular, I have seen a lot of performance problems in the past[1] which stemmed essentially from using lea to do address computations so that the addressing mode operand was simpler. Just want to make sure the LSR and other users of this will be sufficiently conservative.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">[1]: So fun story here. The fact that LLVM so aggressively forms complex addressing modes may explain why this used to be such a big problem for me. It would use every single part of the addressing mode in structuring the loop body, and then during instruction selection we would fail in a large number of cases to match that as an actual addressing mode. I spent a bunch of time teaching the instruction selection layer for x86 to re-constitute every addressing mode it could in order to fix this. This may even become relevant, because while I *tried* to only do these heroics for cases that were strictly better (ie, fewer instructions total), I could have messed it up, and we might re-form complex addressing modes even when unnecessary.</div>
<div class="gmail_extra"><br></div></div>