<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 7, 2015, at 1:30 PM, Sanjay Patel <<a href="mailto:spatel@rotateright.com" class="">spatel@rotateright.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">I forgot to update the SLP thread from last week. I have a patch up for review that would allow creating wider vectors as requested, but may increase SLP compile time:<br class=""><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10950&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=yVgv4N6j_JRVgMR8WDA9CopjaUXxuRZAxKwygcfn3O0&s=xnk-xGH432NOLwUMT2kPF4BfzWpF3uAW_WMfVaAeVE4&e=" target="_blank" class="">http://reviews.llvm.org/D10950</a><br class=""><br class="">An audit of the trunk backends shows that only PowerPC + QPX and x86 + 
AVX / AVX512 would potentially get an extra round of store merging from the use of 
'getRegisterBitWidth()'. <br class=""><br class="">As reported in the phab comments, I didn't see any compile time hit on test-suite for an AVX machine. I'm very curious to know if that patch causes further blowup in this example.<br class=""></div></div></div></blockquote>Thanks for the heads up, Sanjay! I think that effect from your patch wouldn’t be that big even in this case, because I don’t think that vectorizeStoreChain is a bottleneck here (disclaimer: that’s just my plain speculations). But it’s always good to check:)</div><div><br class=""></div><div>Michael<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div>Frank, what causes a 10^6 instruction function to be generated? Can this be rolled into a loop?<br class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Jul 7, 2015 at 12:55 PM, Michael Zolotukhin <span dir="ltr" class=""><<a href="mailto:mzolotukhin@apple.com" target="_blank" class="">mzolotukhin@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Frank,<br class="">
<br class="">
The most time consuming part of SLP vectorizer (especially in cases like yours) is finding sets of consecutive stores. It's currently performed by a quadratic search (see routine SLPVectorizer::vectorizeStores) - we do pairwise comparisons between all pointers (but we do limit ourselves to look at at most 16 stores). I think it should be possible to group pointers with a common base, compute constant relative offset and just sort all of them - this way we’ll save a lot of expensive computations. However, I haven’t tried implementing this, and I guess there might be some hard corner cases too. Patches would be welcome here:)<br class="">
<br class="">
Thanks,<br class="">
Michael<br class="">
<div class="HOEnZb"><div class="h5"><br class="">
> On Jul 7, 2015, at 11:31 AM, Frank Winter <<a href="mailto:fwinter@jlab.org" class="">fwinter@jlab.org</a>> wrote:<br class="">
><br class="">
> Hi all!<br class="">
><br class="">
> It takes the current SLP vectorizer too long to vectorize my scalar code. I am talking here about functions that have a single, huge basic block with O(10^6) instructions. Here's an example:<br class="">
><br class="">
>  %0 = getelementptr float* %arg1, i32 49<br class="">
>  %1 = load float* %0<br class="">
>  %2 = getelementptr float* %arg1, i32 4145<br class="">
>  %3 = load float* %2<br class="">
>  %4 = getelementptr float* %arg2, i32 49<br class="">
>  %5 = load float* %4<br class="">
>  %6 = getelementptr float* %arg2, i32 4145<br class="">
>  %7 = load float* %6<br class="">
>  %8 = fmul float %7, %1<br class="">
>  %9 = fmul float %5, %3<br class="">
>  %10 = fadd float %9, %8<br class="">
>  %11 = fmul float %7, %3<br class="">
>  %12 = fmul float %5, %1<br class="">
>  %13 = fsub float %12, %11<br class="">
>  %14 = getelementptr float* %arg3, i32 16<br class="">
>  %15 = load float* %14<br class="">
>  %16 = getelementptr float* %arg3, i32 4112<br class="">
>  %17 = load float* %16<br class="">
>  %18 = getelementptr float* %arg4, i32 0<br class="">
>  %19 = load float* %18<br class="">
>  %20 = getelementptr float* %arg4, i32 4096<br class="">
>  %21 = load float* %20<br class="">
>  %22 = fmul float %21, %15<br class="">
>  %23 = fmul float %19, %17<br class="">
>  %24 = fadd float %23, %22<br class="">
>  %25 = fmul float %21, %17<br class="">
>  %26 = fmul float %19, %15<br class="">
>  %27 = fsub float %26, %25<br class="">
>  %28 = fadd float %24, %10<br class="">
>  %29 = fadd float %27, %13<br class="">
>  %30 = getelementptr float* %arg0, i32 0<br class="">
>  store float %29, float* %30<br class="">
>  %31 = getelementptr float* %arg0, i32 4096<br class="">
>  store float %28, float* %31<br class="">
> ... and so on ...<br class="">
><br class="">
> The SLP vectorizer would create some code like this:<br class="">
><br class="">
>  %219 = insertelement <4 x float> %218, float %185, i32 2<br class="">
>  %220 = insertelement <4 x float> %219, float %197, i32 3<br class="">
>  %221 = fmul <4 x float> %216, %220<br class="">
>  %222 = fadd <4 x float> %221, %212<br class="">
>  %223 = fmul <4 x float> %207, %220<br class="">
> ..<br class="">
>  %234 = bitcast float* %165 to <4 x float>*<br class="">
>  store <4 x float> %233, <4 x float>* %234, align 4<br class="">
><br class="">
><br class="">
> With the current SLP implementation 99.5% of the time is spent in the SLP vectorizer and I have the impression that this can be improved for my case. I believe that the SLP vectorizer has far more capabilities than I would need for these simple (but huge) functions. And I was hoping that any of you have an idea how to remove functionality of the SLP vectorizer such that it still can vectorize those simple functions...?<br class="">
><br class="">
> Thanks,<br class="">
> Frank<br class="">
><br class="">
> _______________________________________________<br class="">
> LLVM Developers mailing list<br class="">
> <a href="mailto:LLVMdev@cs.uiuc.edu" class="">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu/" rel="noreferrer" target="_blank" class="">http://llvm.cs.uiuc.edu</a><br class="">
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:LLVMdev@cs.uiuc.edu" class="">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu/" rel="noreferrer" target="_blank" class="">http://llvm.cs.uiuc.edu</a><br class="">
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br class="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>