<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Fixed these in <span class="Apple-style-span" style="font-size: 12px; font-weight: bold; ">r85933.</span><div><b><br></b></div><div><span class="Apple-style-span" style="font-size: 12px; "></span><b>Victor</b></div><div><b><br></b><div><div>On Nov 2, 2009, at 8:29 PM, Chris Lattner wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Nov 2, 2009, at 10:51 AM, Victor Hernandez wrote:<br><blockquote type="cite">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=85814&view=rev">http://llvm.org/viewvc/llvm-project?rev=85814&view=rev</a><br></blockquote><blockquote type="cite">Log:<br></blockquote><blockquote type="cite">Set bit instead of calling pow() to compute 2 << n<br></blockquote><br>Thanks Victor,<br><br><blockquote type="cite">+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Mon Nov  2 12:51:28 2009<br></blockquote><blockquote type="cite">@@ -16,6 +16,7 @@<br></blockquote><blockquote type="cite">#include "llvm/Constants.h"<br></blockquote><blockquote type="cite">#include "llvm/Instructions.h"<br></blockquote><blockquote type="cite">#include "llvm/Module.h"<br></blockquote><blockquote type="cite">+#include "llvm/ADT/APInt.h"<br></blockquote><br>You don't need this #include, please remove it.<br><br><blockquote type="cite">@@ -156,15 +157,22 @@<br></blockquote><blockquote type="cite">        return Op1;<br></blockquote><blockquote type="cite">    }<br></blockquote><blockquote type="cite">    if (Opcode == Instruction::Shl) {<br></blockquote><blockquote type="cite">-      ConstantInt* Op1Int = dyn_cast<ConstantInt>(Op1);<br></blockquote><blockquote type="cite">-      if (!Op1Int) return NULL;<br></blockquote><blockquote type="cite">-      Value* Op1Pow = ConstantInt::get(Op1->getType(), (uint64_t)<br></blockquote><blockquote type="cite">-                                    pow(2.0, (double) Op1Int->getZExtValue()));<br></blockquote><blockquote type="cite">+      ConstantInt* Op1CI = dyn_cast<ConstantInt>(Op1);<br></blockquote><blockquote type="cite">+      if (!Op1CI) return NULL;<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">+      APInt Op1Int = Op1CI->getValue();<br></blockquote><blockquote type="cite">+      unsigned Op1Width = Op1Int.getBitWidth();<br></blockquote><blockquote type="cite">+      // check for overflow<br></blockquote><blockquote type="cite">+      if (Op1Int.getActiveBits() > 64 || Op1Int.getZExtValue() > Op1Width)<br></blockquote><blockquote type="cite">+        return NULL;<br></blockquote><br>If the shift overflows, the original code is undefined.  Please just use the APInt::getLimitedValue method  (with the bitwidth as the argument) to handle this.  You'll end up with much more elegant code.<br><br>Finally, please use:<br><br>  ConstantInt *Op1CI<br>instead of:<br>  ConstantInt* Op1CI<br><br>With Op1CI and many other variables in this file.<br><br>Thanks,<br><br>-Chris<br><br><br><br><blockquote type="cite">+      Value* Op1Pow = ConstantInt::get(Context,<br></blockquote><blockquote type="cite">+                                 APInt(Op1Width, 0).set(Op1Int.getZExtValue()));<br></blockquote><blockquote type="cite">+<br></blockquote><blockquote type="cite">      if (Op0 == ElementSize || (FoldedElementSize && Op0 == FoldedElementSize))<br></blockquote><blockquote type="cite">        // ArraySize << log2(ElementSize)<br></blockquote><blockquote type="cite">        return Op1Pow;<br></blockquote><blockquote type="cite">      if (Op1Pow == ElementSize ||<br></blockquote><blockquote type="cite">-        (FoldedElementSize && Op1Pow == FoldedElementSize))<br></blockquote><blockquote type="cite">+          (FoldedElementSize && Op1Pow == FoldedElementSize))<br></blockquote><blockquote type="cite">        // ElementSize << log2(ArraySize)<br></blockquote><blockquote type="cite">        return Op0;<br></blockquote><blockquote type="cite">    }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">llvm-commits mailing list<br></blockquote><blockquote type="cite"><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br></blockquote><blockquote type="cite"><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></blockquote><br></div></blockquote></div><br></div></body></html>