<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 30, 2013, at 2:23 PM, Jim Grosbach <<a href="mailto:grosbach@apple.com">grosbach@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">That used to be true. These days, we see lots of shuffles coming from SROA and we have to mess with them or things go very badly.  </div></blockquote><div><br></div><div>You can change SROA to reduce the number of shuffle vectors. I scanned SROA and I did not see anything too bad. I only saw insert/extract and blend, which should map nicely to any vector ISA.  But you can make things better by changing SROA.cpp::insertVector to generate a select instruction, instead of a vector shuffle.</div><div> </div><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">The more I think about it, the more I disagree with the current design. It creates a very deep tight coupling between what InstCombine does and the least-common-denominator of what target codegen can handle. That’s untenable in the long term and artificially restrictive.</div></blockquote><div><br></div><div>The motivation for the current design (which I am happy with) is that it is very difficult to undo a canonicalization of shuffles because the search space is huge. Also, the clang shuffle builtins are used by people who optimize their performance sensitive applications. </div><div><br></div><div>We use this approach in other places in the compiler. We don't always canonicalize all the way and in many cases we prefer not to touch the program unless we are certain that the change is beneficial.  The shuffle ISA is so sparse that merging shuffles are likely to cause regressions. </div><div>   </div><div><br></div><blockquote type="cite"><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">When I looked at the test case I noticed that some of your shuffles were actually vector blends. It would make sense to convert blend-shuffles into select instructions with a constant mask.    </div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Sounds like a good idea. I don’t know much about the provenance of the original IR of these test cases.</div></blockquote></div><br></body></html>