[llvm-commits] [dragonegg] r131180 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp
Duncan Sands
baldrick at free.fr
Wed May 11 05:04:25 PDT 2011
Author: baldrick
Date: Wed May 11 07:04:24 2011
New Revision: 131180
URL: http://llvm.org/viewvc/llvm-project?rev=131180&view=rev
Log:
Add support for VEC_UNPACK_HI_EXPR and VEC_UNPACK_LO_EXPR which the
GCC tree vectorizer may produce when GCC optimizations are enabled.
This fixes PR9714.
Modified:
dragonegg/trunk/include/dragonegg/Internals.h
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=131180&r1=131179&r2=131180&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Wed May 11 07:04:24 2011
@@ -723,6 +723,8 @@
Value *EmitReg_VEC_INTERLEAVE_LOW_EXPR(tree_node *op0, tree_node *op1);
Value *EmitReg_VEC_PACK_TRUNC_EXPR(tree_node *type, tree_node *op0,
tree_node *op1);
+ Value *EmitReg_VEC_UNPACK_HI_EXPR(tree_node *type, tree_node *op0);
+ Value *EmitReg_VEC_UNPACK_LO_EXPR(tree_node *type, tree_node *op0);
Value *EmitLoadOfLValue(tree_node *exp);
Value *EmitOBJ_TYPE_REF(tree_node *exp);
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131180&r1=131179&r2=131180&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed May 11 07:04:24 2011
@@ -7024,6 +7024,52 @@
return Builder.CreateShuffleVector(LHS, RHS, ConstantVector::get(Mask));
}
+Value *TreeToLLVM::EmitReg_VEC_UNPACK_HI_EXPR(tree type, tree op0) {
+ // Eg: <2 x double> = VEC_UNPACK_HI_EXPR(<4 x float>)
+ Value *Op = EmitRegister(op0);
+
+ // Extract the high elements, eg: <4 x float> -> <2 x float>.
+ unsigned Length = TYPE_VECTOR_SUBPARTS(type);
+ SmallVector<Constant*, 16> Mask;
+ Mask.reserve(Length);
+ for (unsigned i = 0; i != Length; ++i)
+ Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), Length + i));
+ Op = Builder.CreateShuffleVector(Op, UndefValue::get(Op->getType()),
+ ConstantVector::get(Mask));
+
+ // Extend the input elements to the output element type, eg: <2 x float>
+ // -> <2 x double>.
+ const Type *ExtTy = getRegType(type);
+ if (FLOAT_TYPE_P(TREE_TYPE(TREE_TYPE(op0))))
+ return Builder.CreateFPExt(Op, ExtTy);
+ if (TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(op0))))
+ return Builder.CreateZExt(Op, ExtTy);
+ return Builder.CreateSExt(Op, ExtTy);
+}
+
+Value *TreeToLLVM::EmitReg_VEC_UNPACK_LO_EXPR(tree type, tree op0) {
+ // Eg: <2 x double> = VEC_UNPACK_LO_EXPR(<4 x float>)
+ Value *Op = EmitRegister(op0);
+
+ // Extract the low elements, eg: <4 x float> -> <2 x float>.
+ unsigned Length = TYPE_VECTOR_SUBPARTS(type);
+ SmallVector<Constant*, 16> Mask;
+ Mask.reserve(Length);
+ for (unsigned i = 0; i != Length; ++i)
+ Mask.push_back(ConstantInt::get(Type::getInt32Ty(Context), i));
+ Op = Builder.CreateShuffleVector(Op, UndefValue::get(Op->getType()),
+ ConstantVector::get(Mask));
+
+ // Extend the input elements to the output element type, eg: <2 x float>
+ // -> <2 x double>.
+ const Type *ExtTy = getRegType(type);
+ if (FLOAT_TYPE_P(TREE_TYPE(TREE_TYPE(op0))))
+ return Builder.CreateFPExt(Op, ExtTy);
+ if (TYPE_UNSIGNED(TREE_TYPE(TREE_TYPE(op0))))
+ return Builder.CreateZExt(Op, ExtTy);
+ return Builder.CreateSExt(Op, ExtTy);
+}
+
//===----------------------------------------------------------------------===//
// ... Exception Handling ...
@@ -7991,6 +8037,10 @@
RHS = EmitReg_VEC_INTERLEAVE_LOW_EXPR(rhs1, rhs2); break;
case VEC_PACK_TRUNC_EXPR:
RHS = EmitReg_VEC_PACK_TRUNC_EXPR(type, rhs1, rhs2); break;
+ case VEC_UNPACK_HI_EXPR:
+ RHS = EmitReg_VEC_UNPACK_HI_EXPR(type, rhs1); break;
+ case VEC_UNPACK_LO_EXPR:
+ RHS = EmitReg_VEC_UNPACK_LO_EXPR(type, rhs1); break;
}
assert(RHS->getType() == getRegType(type) && "RHS has wrong type!");
More information about the llvm-commits
mailing list