[llvm-commits] [dragonegg] r168869 - in /dragonegg/branches/release_32: src/x86/Target.cpp src/x86/x86_builtins test/validator/c/copysignp.c
Duncan Sands
baldrick at free.fr
Thu Nov 29 03:35:45 PST 2012
Author: baldrick
Date: Thu Nov 29 05:35:45 2012
New Revision: 168869
URL: http://llvm.org/viewvc/llvm-project?rev=168869&view=rev
Log:
Backport the fix for PR12664 (r168787) to the 3.2 branch. Original commit
message:
Add support for GCC's vector copysign builtins, fixing PR12664.
Added:
dragonegg/branches/release_32/test/validator/c/copysignp.c
Modified:
dragonegg/branches/release_32/src/x86/Target.cpp
dragonegg/branches/release_32/src/x86/x86_builtins
Modified: dragonegg/branches/release_32/src/x86/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_32/src/x86/Target.cpp?rev=168869&r1=168868&r2=168869&view=diff
==============================================================================
--- dragonegg/branches/release_32/src/x86/Target.cpp (original)
+++ dragonegg/branches/release_32/src/x86/Target.cpp Thu Nov 29 05:35:45 2012
@@ -165,6 +165,29 @@
case addpd256:
Result = Builder.CreateFAdd(Ops[0], Ops[1]);
return true;
+ case copysignpd:
+ case copysignpd256:
+ case copysignps:
+ case copysignps256: {
+ if (Ops.size() != 2)
+ return false;
+ VectorType *VecTy = dyn_cast<VectorType>(Ops[0]->getType());
+ if (Ops[1]->getType() != VecTy)
+ return false;
+ Type *EltTy = VecTy->getElementType();
+ unsigned EltBitWidth = EltTy->getPrimitiveSizeInBits();
+ Type *IntEltTy = IntegerType::get(Context, EltBitWidth);
+ Type *IntVecTy = VectorType::get(IntEltTy, VecTy->getNumElements());
+ APInt SignBit = APInt::getSignBit(EltBitWidth);
+ Constant *SignMask = ConstantInt::get(IntVecTy, SignBit);
+ Value *IntLHS = Builder.CreateBitCast(Ops[0], IntVecTy);
+ Value *IntRHS = Builder.CreateBitCast(Ops[1], IntVecTy);
+ Value *Sign = Builder.CreateAnd(IntRHS, SignMask);
+ Value *Abs = Builder.CreateAnd(IntLHS, ConstantExpr::getNot(SignMask));
+ Value *IntRes = Builder.CreateOr(Abs, Sign);
+ Result = Builder.CreateBitCast(IntRes, VecTy);
+ return true;
+ }
case paddb:
case paddw:
case paddd:
Modified: dragonegg/branches/release_32/src/x86/x86_builtins
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_32/src/x86/x86_builtins?rev=168869&r1=168868&r2=168869&view=diff
==============================================================================
--- dragonegg/branches/release_32/src/x86/x86_builtins (original)
+++ dragonegg/branches/release_32/src/x86/x86_builtins Thu Nov 29 05:35:45 2012
@@ -120,10 +120,10 @@
//DEFINE_BUILTIN(comisdle),
//DEFINE_BUILTIN(comisdlt),
//DEFINE_BUILTIN(comisdneq),
-//DEFINE_BUILTIN(copysignpd),
-//DEFINE_BUILTIN(copysignpd256),
-//DEFINE_BUILTIN(copysignps),
-//DEFINE_BUILTIN(copysignps256),
+DEFINE_BUILTIN(copysignpd),
+DEFINE_BUILTIN(copysignpd256),
+DEFINE_BUILTIN(copysignps),
+DEFINE_BUILTIN(copysignps256),
//DEFINE_BUILTIN(crc32di),
//DEFINE_BUILTIN(crc32hi),
//DEFINE_BUILTIN(crc32qi),
Added: dragonegg/branches/release_32/test/validator/c/copysignp.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_32/test/validator/c/copysignp.c?rev=168869&view=auto
==============================================================================
--- dragonegg/branches/release_32/test/validator/c/copysignp.c (added)
+++ dragonegg/branches/release_32/test/validator/c/copysignp.c Thu Nov 29 05:35:45 2012
@@ -0,0 +1,7 @@
+// RUN: %dragonegg -S %s
+// PR12664
+
+typedef float v4sf __attribute__ ((vector_size (16)));
+v4sf foo(v4sf l, v4sf r) {
+ return __builtin_ia32_copysignps (l, r);
+}
More information about the llvm-commits
mailing list