From c92151516f4630a2cabcb9b8e5edbd565e16a219 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Sun, 4 Sep 2011 11:45:52 +0000 Subject: CodeGen: Support for Cast Operations in vector code generation llvm-svn: 139097 --- polly/lib/CodeGeneration.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'polly/lib/CodeGeneration.cpp') diff --git a/polly/lib/CodeGeneration.cpp b/polly/lib/CodeGeneration.cpp index cb8a01f4ed4..10e96baa20b 100644 --- a/polly/lib/CodeGeneration.cpp +++ b/polly/lib/CodeGeneration.cpp @@ -409,6 +409,21 @@ public: vectorMap[load] = newLoad; } + void copyUnaryInst(const UnaryInstruction *Inst, ValueMapT &BBMap, + ValueMapT &VectorMap, int VectorDimension, + int VectorWidth) { + Value *NewOperand = getOperand(Inst->getOperand(0), BBMap, &VectorMap); + NewOperand = makeVectorOperand(NewOperand, VectorWidth); + + if (const CastInst *Cast = dyn_cast(Inst)) { + VectorType *DestType = VectorType::get(Inst->getType(), VectorWidth); + VectorMap[Inst] = Builder.CreateCast(Cast->getOpcode(), NewOperand, + DestType); + } else + llvm_unreachable("Can not generate vector code for instruction"); + return; + } + void copyBinInst(const BinaryOperator *Inst, ValueMapT &BBMap, ValueMapT &vectorMap, int vectorDimension, int vectorWidth) { Value *opZero = Inst->getOperand(0); @@ -529,7 +544,11 @@ public: } if (isVectorBlock() && hasVectorOperands(Inst, vectorMap)) { - if (const BinaryOperator *binaryInst = dyn_cast(Inst)) + if (const UnaryInstruction *UnaryInst = dyn_cast(Inst)) + copyUnaryInst(UnaryInst, BBMap, vectorMap, vectorDimension, + vectorWidth); + else if + (const BinaryOperator *binaryInst = dyn_cast(Inst)) copyBinInst(binaryInst, BBMap, vectorMap, vectorDimension, vectorWidth); else if (const StoreInst *store = dyn_cast(Inst)) copyVectorStore(store, BBMap, vectorMap, scalarMaps, vectorDimension, -- cgit v1.2.3