<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Apr 25, 2014, at 7:53 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:<br><div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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></blockquote><br></div><div>The "right" answer here is to introduce a new llvm intrinsic to represent addressing modes.  It is ridiculous that LSR and CGP generate LLVM "very carefully" with the expectation that selection dag will be able to reconstitute it... and that nothing between them will mess things up.</div><div><br></div><div>-Chris</div><br></body></html>