aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/Local.cpp5
-rw-r--r--lib/Transforms/Utils/ValueMapper.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index a35a1a6..a848e74 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -107,6 +107,11 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I) {
case Instruction::InsertElement:
if (Constant *Op2 = dyn_cast<Constant>(I->getOperand(2)))
return ConstantExpr::getInsertElement(Op0, Op1, Op2);
+ return 0;
+ case Instruction::ShuffleVector:
+ if (Constant *Op2 = dyn_cast<Constant>(I->getOperand(2)))
+ return ConstantExpr::getShuffleVector(Op0, Op1, Op2);
+ return 0;
case Instruction::GetElementPtr:
std::vector<Constant*> IdxList;
IdxList.reserve(I->getNumOperands()-1);
diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp
index 3093aca..b309f9c 100644
--- a/lib/Transforms/Utils/ValueMapper.cpp
+++ b/lib/Transforms/Utils/ValueMapper.cpp
@@ -94,6 +94,11 @@ Value *llvm::MapValue(const Value *V, std::map<const Value*, Value*> &VM) {
Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
return VMSlot = ConstantExpr::getExtractElement(MV1, MV2);
+ } else if (CE->getOpcode() == Instruction::ShuffleVector) {
+ Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));
+ Constant *MV2 = cast<Constant>(MapValue(CE->getOperand(1), VM));
+ Constant *MV3 = cast<Constant>(CE->getOperand(2));
+ return VMSlot = ConstantExpr::getShuffleVector(MV1, MV2, MV3);
} else {
assert(CE->getNumOperands() == 2 && "Must be binary operator?");
Constant *MV1 = cast<Constant>(MapValue(CE->getOperand(0), VM));