<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;" class="">Hi Jason,<div class=""><br class=""></div><div class="">I am guessing that the problem is that we do not recognize the sequence as rematerializable because, we do not directly load LCPI0_212 into a ymm register.</div><div class="">One way to fix that is by using a pseudo instruction that does the load from the constant to ymm (while defining a dead GPR register to be able to expand the pseudo), then teach the folding code how to deal with that.</div><div class=""><br class=""></div><div class="">Another option is to make the rematerialization smarter, but that is more complicated :).</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Quentin <br class=""><div><blockquote type="cite" class=""><div class="">On May 9, 2016, at 2:41 PM, Jason via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Does anyone have any insight into this problem? Is there a way to minimize excessive spill/fill for this kind of scenario?</div><div class="">Thanks,</div><div class="">Jason</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, May 6, 2016 at 10:44 AM, Jason <span dir="ltr" class=""><<a href="mailto:thesurprises@gmail.com" target="_blank" class="">thesurprises@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><span style="font-size:12.8px" class="">Hi, I am using mcjit in llvm 3.6 to jit kernels to x86 avx2. I've noticed some inefficient use of the stack around constant vectors. In one example, I have code that computes a series of constant vectors at compile time. Each vector has a single use. In the final asm, I see a series of spills at the top of the function of all the constant vectors immediately to stack, then each use references the stack pointer directly:</span><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">Lots of these at top of function:</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class=""><div class=""><span style="white-space:pre-wrap" class="">  </span>movabsq<span style="white-space:pre-wrap" class="">      </span>$.LCPI0_212, %rbx</div><div class=""><span style="white-space:pre-wrap" class="">  </span>vmovaps<span style="white-space:pre-wrap" class="">      </span>(%rbx), %ymm0</div><div class=""><span style="white-space:pre-wrap" class="">      </span>vmovaps<span style="white-space:pre-wrap" class="">      </span>%ymm0, 2816(%rsp)       # 32-byte Spill<br class=""></div></div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">Later on, each use references the stack pointer:</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class=""><span style="white-space:pre-wrap" class="">        </span>vpaddd<span style="white-space:pre-wrap" class="">       </span>2816(%rsp), %ymm4, %ymm1 # 32-byte Folded Reload</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">It seems the spill to stack is unnecessary. In one particularly bad kernel, I have 128 8-wide constant vectors, and so there is 4KB of stack use just for these constants. I think a better approach could be to load the constant vector pointers as needed:</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class=""><span style="white-space:pre-wrap" class="">  </span>movabsq<span style="white-space:pre-wrap" class="">      </span>$.LCPI0_212, %rbx</div><div style="font-size:12.8px" class=""><span style="white-space:pre-wrap" class="">       </span>vpaddd<span style="white-space:pre-wrap" class="">       (</span>%rbx), %ymm4, %ymm1</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">Thanks,</div><div style="font-size:12.8px" class="">Jason</div></div>
</blockquote></div><br class=""></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>