[PATCH] Convert index operand to 32bit before creating the shuffle mask
Moritz Pflanzer
moritz at pflanzer.eu
Tue Jun 30 07:54:52 PDT 2015
This patch fixes bug 23800. There existed a case where the index operand from extractelement was directly used to create a shufflevector mask. Since the index can be of any integral type but the mask must only contain 32 bit integers a 64 bit index operand led to an assertion error later on.
http://reviews.llvm.org/D10838
Files:
lib/CodeGen/CGExprScalar.cpp
Index: lib/CodeGen/CGExprScalar.cpp
===================================================================
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -1215,7 +1215,13 @@
Value *LHS = nullptr, *RHS = nullptr;
if (CurIdx == 0) {
// insert into undef -> shuffle (src, undef)
- Args.push_back(C);
+ // extractelement index can be any integer type
+ // shufflemask is only allowed to contain 32 bit integers
+ // make sure we can savely convert to 32 bit
+ 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();
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10838.28781.patch
Type: text/x-patch
Size: 959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150630/488694f6/attachment.bin>
More information about the cfe-commits
mailing list