<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Jan 10, 2015 at 11:09 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><br><div class="gmail_quote">On Sat, Jan 10, 2015 at 9:08 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="overflow:hidden">- assert((NumElements == 16 || NumElements == 32) &&<br>
- "Only 128-bit and 256-bit vectors supported!");<br>
+ if (!DestTy)<br>
+ return;<br>
+<br>
+ if (DestTy != MaskTy) {<br>
+ if (!CastInst::castIsValid(Instruction::BitCast, const_cast<Constant *>(C),<br>
+ DestTy))<br>
+ return;<br>
+<br>
+ C = ConstantFoldInstOperands(Instruction::BitCast, DestTy,<br>
+ const_cast<Constant *>(C), TD);<br>
+ MaskTy = DestTy;<br>
+ }</div></blockquote></div><br></span>No no no, you don't get to play fast and loose by constant folding here. =]</div><div class="gmail_extra"><br></div><div class="gmail_extra">You may not have a module, your context may be very different than you expect. =/</div><div class="gmail_extra"><br></div><div class="gmail_extra">I would just do the bit math manually.</div></div>
</blockquote></div><br></div><div class="gmail_extra">I've reverted the parts that cause the build bots to get upset in r225599.</div><div class="gmail_extra"><br></div><div class="gmail_extra">As discussed on IRC, this code is only used in the code-generating parts of LLVM, we will always have a Module, etc. However, those who which to link with this micro-library might not have the target specific constant folder.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Strangely, the CMake build is fine with where the code was living while the autoconf build failed to link the MC unittest. I've got a feeling that the link dependencies have diverged somewhere.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regardless, I think the right thing to do is to take this code (with it's use of the target-specific constant folder) and move it to a more relevant place in the X86 backend. The question is where?</div></div>