[LLVMdev] [llvm-commits] [dragonegg] r168787 - in /dragonegg/trunk: src/x86/Target.cpp src/x86/x86_builtins test/validator/c/copysignp.c
Duncan Sands
baldrick at free.fr
Wed Nov 28 04:53:51 PST 2012
Hi Pawel, can you please pull this dragonegg patch into 3.2. I am the
code owner for dragonegg.
Thanks a lot, Duncan.
On 28/11/12 13:44, Duncan Sands wrote:
> Author: baldrick
> Date: Wed Nov 28 06:44:50 2012
> New Revision: 168787
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168787&view=rev
> Log:
> Add support for GCC's vector copysign builtins, fixing PR12664.
>
> Added:
> dragonegg/trunk/test/validator/c/copysignp.c
> Modified:
> dragonegg/trunk/src/x86/Target.cpp
> dragonegg/trunk/src/x86/x86_builtins
>
> Modified: dragonegg/trunk/src/x86/Target.cpp
> URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/x86/Target.cpp?rev=168787&r1=168786&r2=168787&view=diff
> ==============================================================================
> --- dragonegg/trunk/src/x86/Target.cpp (original)
> +++ dragonegg/trunk/src/x86/Target.cpp Wed Nov 28 06:44:50 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/trunk/src/x86/x86_builtins
> URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/x86/x86_builtins?rev=168787&r1=168786&r2=168787&view=diff
> ==============================================================================
> --- dragonegg/trunk/src/x86/x86_builtins (original)
> +++ dragonegg/trunk/src/x86/x86_builtins Wed Nov 28 06:44:50 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/trunk/test/validator/c/copysignp.c
> URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/copysignp.c?rev=168787&view=auto
> ==============================================================================
> --- dragonegg/trunk/test/validator/c/copysignp.c (added)
> +++ dragonegg/trunk/test/validator/c/copysignp.c Wed Nov 28 06:44:50 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);
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-dev
mailing list