<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 17, 2015 at 2:30 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div><span class="">On Thu, Apr 16, 2015 at 11:10 AM, Sanjay Patel <span dir="ltr"><<a href="mailto:spatel@rotateright.com" target="_blank">spatel@rotateright.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi Sean -<br><br></div>Thanks for pushing on this. <br><br>Re: the complicated cases - in one of the recent patch reviews in this area, Andrea pointed out a major shortcoming of the header hacks: we're optimizing vector intrinsics into generic IR even at -O0. This won't make for happy debugging. <br><br>So I've been optimizing these in InstCombine rather than headers recently:<br><a href="http://reviews.llvm.org/rL235124" target="_blank">http://reviews.llvm.org/rL235124</a><br><a href="http://reviews.llvm.org/rL232852" target="_blank">http://reviews.llvm.org/rL232852</a><br><br></div>This is a much nicer solution IMO, and I haven't heard any objections to this approach, so I'm hoping we'll clean up all of the complicated macros eventually.<br></div></blockquote><div><br></div></span><div>How are you handling the frontend checks for them being a compile-time constant? I think that at the very least the enable_if will allow removing the macros which I thought were just for that purpose (or are you planning on adding the intrinsics directly as clang intrinsics?).</div><span class="HOEnZb"></span> <br></div></div></div></blockquote><div><br></div><div>Handling the intrinsics in InstCombine decouples the optimization part of the problem from the constant checking. So if we can handle the simple macros using enable_if, then we should be able to convert the complicated macros back into their original simple inline function forms + enable_if checking and do all of the optimization work in InstCombine for those cases too. <br><br>Put another way: if enable_if works for one case, then we should be able to make it work for all cases and eventually have a uniform header file; each intrinsic can be a simple function call with all optimization deferred to InstCombine.<br></div><div><br> </div></div></div></div>