[llvm-commits] [polly] r139097 - in /polly/trunk: lib/CodeGeneration.cpp test/CodeGen/simple_vec_cast.ll
Tobias Grosser
grosser at fim.uni-passau.de
Sun Sep 4 04:45:52 PDT 2011
Author: grosser
Date: Sun Sep 4 06:45:52 2011
New Revision: 139097
URL: http://llvm.org/viewvc/llvm-project?rev=139097&view=rev
Log:
CodeGen: Support for Cast Operations in vector code generation
Added:
polly/trunk/test/CodeGen/simple_vec_cast.ll
Modified:
polly/trunk/lib/CodeGeneration.cpp
Modified: polly/trunk/lib/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=139097&r1=139096&r2=139097&view=diff
==============================================================================
--- polly/trunk/lib/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGeneration.cpp Sun Sep 4 06:45:52 2011
@@ -409,6 +409,21 @@
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<CastInst>(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 @@
}
if (isVectorBlock() && hasVectorOperands(Inst, vectorMap)) {
- if (const BinaryOperator *binaryInst = dyn_cast<BinaryOperator>(Inst))
+ if (const UnaryInstruction *UnaryInst = dyn_cast<UnaryInstruction>(Inst))
+ copyUnaryInst(UnaryInst, BBMap, vectorMap, vectorDimension,
+ vectorWidth);
+ else if
+ (const BinaryOperator *binaryInst = dyn_cast<BinaryOperator>(Inst))
copyBinInst(binaryInst, BBMap, vectorMap, vectorDimension, vectorWidth);
else if (const StoreInst *store = dyn_cast<StoreInst>(Inst))
copyVectorStore(store, BBMap, vectorMap, scalarMaps, vectorDimension,
Added: polly/trunk/test/CodeGen/simple_vec_cast.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/simple_vec_cast.ll?rev=139097&view=auto
==============================================================================
--- polly/trunk/test/CodeGen/simple_vec_cast.ll (added)
+++ polly/trunk/test/CodeGen/simple_vec_cast.ll Sun Sep 4 06:45:52 2011
@@ -0,0 +1,33 @@
+; RUN: opt %loadPolly -basicaa -polly-codegen -enable-polly-vector -dce -S %s | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at A = common global [1024 x float] zeroinitializer, align 16
+ at B = common global [1024 x double] zeroinitializer, align 16
+
+define void @simple_vec_const() nounwind {
+bb:
+ br label %bb1
+
+bb1: ; preds = %bb3, %bb
+ %indvar = phi i64 [ %indvar.next, %bb3 ], [ 0, %bb ]
+ %scevgep = getelementptr [1024 x double]* @B, i64 0, i64 %indvar
+ %exitcond = icmp ne i64 %indvar, 4
+ br i1 %exitcond, label %bb2, label %bb4
+
+bb2: ; preds = %bb1
+ %tmp = load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 0), align 16
+ %tmp2 = fpext float %tmp to double
+ store double %tmp2, double* %scevgep, align 4
+ br label %bb3
+
+bb3: ; preds = %bb2
+ %indvar.next = add i64 %indvar, 1
+ br label %bb1
+
+bb4: ; preds = %bb1
+ ret void
+}
+
+; CHECK: fpext <4 x float> %tmp_p_splat to <4 x double>
+
More information about the llvm-commits
mailing list