[PATCH] D10838: Fix invalid shufflevector operands

Moritz Pflanzer moritz.pflanzer14 at imperial.ac.uk
Tue Jul 7 15:53:26 PDT 2015



Avoid re-uniquing the constant when it already is an i32


http://reviews.llvm.org/D10838

Files:
  lib/CodeGen/CGExprScalar.cpp

Index: lib/CodeGen/CGExprScalar.cpp
===================================================================
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -1216,7 +1216,15 @@
           Value *LHS = nullptr, *RHS = nullptr;
           if (CurIdx == 0) {
             // insert into undef -> shuffle (src, undef)
-            Args.push_back(C);
+            // shufflemask must use an i32
+            if (C->getBitWidth() == 32) {
+                Args.push_back(C);
+            } else {
+                assert(llvm::ConstantInt::isValueValidForType(CGF.Int32Ty,
+                                                              C->getZExtValue())
+                       && "Index operand too large for shufflevector mask!");
+                Args.push_back(Builder.getInt32(C->getZExtValue()));
+            }
             Args.resize(ResElts, llvm::UndefValue::get(CGF.Int32Ty));
 
             LHS = EI->getVectorOperand();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10838.29219.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150707/323d3c35/attachment.bin>


More information about the cfe-commits mailing list