From: Sanjay Patel Date: Thu, 12 Mar 2015 15:27:07 +0000 (+0000) Subject: IRBuilder: add a CreateShuffleVector function that takes an ArrayRef of int X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=656ef652cc9239af52f9ebe0d47151aeb56fddf1;p=oota-llvm.git IRBuilder: add a CreateShuffleVector function that takes an ArrayRef of int This is a convenience function to ease mask creation of ShuffleVectors in AutoUpgrade and other places. Differential Revision: http://reviews.llvm.org/D8184 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232047 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index c86edf98847..bf3115e7f0f 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -1486,6 +1486,16 @@ public: return Insert(new ShuffleVectorInst(V1, V2, Mask), Name); } + Value *CreateShuffleVector(Value *V1, Value *V2, ArrayRef IntMask, + const Twine &Name = "") { + size_t MaskSize = IntMask.size(); + SmallVector MaskVec(MaskSize); + for (size_t i = 0; i != MaskSize; ++i) + MaskVec[i] = getInt32(IntMask[i]); + Value *Mask = ConstantVector::get(MaskVec); + return CreateShuffleVector(V1, V2, Mask, Name); + } + Value *CreateExtractValue(Value *Agg, ArrayRef Idxs, const Twine &Name = "") { diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index 40757053b6c..fab6915a7a7 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -568,11 +568,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { CI->getArgOperand(0), PointerType::getUnqual(VectorType::get(Type::getInt64Ty(C), 2))); Value *Load = Builder.CreateLoad(Op); - SmallVector Idxs; // 0, 1, 0, 1. - for (unsigned i = 0; i != 4; ++i) - Idxs.push_back(Builder.getInt32(i & 1)); + int Idxs[4] = { 0, 1, 0, 1 }; Rep = Builder.CreateShuffleVector(Load, UndefValue::get(Load->getType()), - ConstantVector::get(Idxs)); + Idxs); } else if (Name == "llvm.x86.sse2.psll.dq") { // 128-bit shift left specified in bits. unsigned Shift = cast(CI->getArgOperand(1))->getZExtValue();