<div dir="ltr">How can I find reviewers for the change?<br></div><br><div class="gmail_quote">On Tue Feb 17 2015 at 9:14:39 PM Paweł Bylica <<a href="mailto:chfast@gmail.com">chfast@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Constant folding for shift IR instructions ignores all bits above 32 of second argument (shift amount). Because of that, some undef results are not recognized and APInt can raise an assert failure if second argument has more than 64 bits.<br>
<br>
REPOSITORY<br>
  rL LLVM<br>
<br>
<a href="http://reviews.llvm.org/D7701" target="_blank">http://reviews.llvm.org/D7701</a><br>
<br>
Files:<br>
  lib/IR/ConstantFold.cpp<br>
<br>
Index: lib/IR/ConstantFold.cpp<br>
==============================<u></u>==============================<u></u>=======<br>
--- lib/IR/ConstantFold.cpp<br>
+++ lib/IR/ConstantFold.cpp<br>
@@ -1120,27 +1120,18 @@<br>
         return ConstantInt::get(CI1-><u></u>getContext(), C1V | C2V);<br>
       case Instruction::Xor:<br>
         return ConstantInt::get(CI1-><u></u>getContext(), C1V ^ C2V);<br>
-      case Instruction::Shl: {<br>
-        uint32_t shiftAmt = C2V.getZExtValue();<br>
-        if (shiftAmt < C1V.getBitWidth())<br>
-          return ConstantInt::get(CI1-><u></u>getContext(), C1V.shl(shiftAmt));<br>
-        else<br>
+      case Instruction::Shl:<br>
+        if (C2V.getActiveBits() > 32 || C2V.getZExtValue() >= C1V.getBitWidth())<br>
           return UndefValue::get(C1->getType())<u></u>; // too big shift is undef<br>
-      }<br>
-      case Instruction::LShr: {<br>
-        uint32_t shiftAmt = C2V.getZExtValue();<br>
-        if (shiftAmt < C1V.getBitWidth())<br>
-          return ConstantInt::get(CI1-><u></u>getContext(), C1V.lshr(shiftAmt));<br>
-        else<br>
+        return ConstantInt::get(CI1-><u></u>getContext(), C1V.shl(C2V.getZExtValue()));<br>
+      case Instruction::LShr:<br>
+        if (C2V.getActiveBits() > 32 || C2V.getZExtValue() >= C1V.getBitWidth())<br>
           return UndefValue::get(C1->getType())<u></u>; // too big shift is undef<br>
-      }<br>
-      case Instruction::AShr: {<br>
-        uint32_t shiftAmt = C2V.getZExtValue();<br>
-        if (shiftAmt < C1V.getBitWidth())<br>
-          return ConstantInt::get(CI1-><u></u>getContext(), C1V.ashr(shiftAmt));<br>
-        else<br>
+        return ConstantInt::get(CI1-><u></u>getContext(), C1V.lshr(C2V.getZExtValue()));<br>
+      case Instruction::AShr:<br>
+        if (C2V.getActiveBits() > 32 || C2V.getZExtValue() >= C1V.getBitWidth())<br>
           return UndefValue::get(C1->getType())<u></u>; // too big shift is undef<br>
-      }<br>
+        return ConstantInt::get(CI1-><u></u>getContext(), C1V.ashr(C2V.getZExtValue()));<br>
       }<br>
     }<br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/<u></u>settings/panel/<u></u>emailpreferences/</a><br>
</blockquote></div>