[Beignet] [PATCH] GBE: Fix a bitcast from float vector to wide interger issue in legalize pass.

Yang, Rong R rong.r.yang at intel.com
Sun Nov 9 21:20:44 PST 2014


LGTM, thanks.

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Ruiling Song
> Sent: Monday, November 10, 2014 11:31
> To: beignet at lists.freedesktop.org
> Cc: Song, Ruiling
> Subject: [Beignet] [PATCH] GBE: Fix a bitcast from float vector to wide
> interger issue in legalize pass.
> 
> When bitcast from <4 x float> to i128, we should not use extractelement
> directly.
> Instead, we cast <4 x float> to <4 x i32>, then use extractelement to get
> individual element.
> 
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
>  backend/src/llvm/llvm_legalize.cpp |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/backend/src/llvm/llvm_legalize.cpp
> b/backend/src/llvm/llvm_legalize.cpp
> index ea0e75a..bb09eab 100644
> --- a/backend/src/llvm/llvm_legalize.cpp
> +++ b/backend/src/llvm/llvm_legalize.cpp
> @@ -516,8 +516,15 @@ namespace gbe {
>        Type *splitTy = vecTy->getElementType();
>        unsigned elements = srcTy->getPrimitiveSizeInBits()/splitTy-
> >getPrimitiveSizeInBits();
>        // bitcast large integer from vector, so we do extractElement to get split
> integer
> +      unsigned splitSz = splitTy->getPrimitiveSizeInBits();
> +      Value *src = p->getOperand(0);
> +      // if it is cast from <4 x float> to i128
> +      // we cast <4 x float> to <4 x i32> first
> +      if (!splitTy->isIntegerTy())
> +        src = Builder.CreateBitCast(src,
> + VectorType::get(IntegerType::get(p->getContext(), splitSz),
> + elements));
> +
>        for (unsigned i = 0; i < elements; i++) {
> -        Value *NV = Builder.CreateExtractElement(p->getOperand(0),
> +        Value *NV = Builder.CreateExtractElement(src,
>                        ConstantInt::get(IntegerType::get(p->getContext(), 32), i));
>          split.push_back(NV);
>        }
> --
> 1.7.10.4
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list