[cfe-dev] [OpenCL patch] Half type as native when OpenCL's cl_khr_fp16 extension is enabled

Anton Lokhmotov Anton.Lokhmotov at arm.com
Thu May 17 05:06:02 PDT 2012


Hi David,

Many thanks for your comments.

> Generally the code changes look good.  I would like to see some test
> cases for code generation updates:
> - half constant generation
> - conversion to and from half, with other type being "float"
Please see new test/CodeGenOpenCL/half.cl.

> - ++ and --
OpenCL 1.1 forbids using the increment and decrement operators on
floating-point values.  We haven't open-sourced the semantic check for this,
so it's hard for us to test.  However, incrementing and decrementing a half
variable by 2.0f is done in the above test.

> I have one detailed comment:
> The following part of the patch seems unnecessary.
> I think the existing code should work because the HalfTypeID should be
> lower than the other floating types?
> 
>    @@ -641,7 +641,10 @@ Value
> *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
>       } else {
>         assert(SrcTy->isFloatingPointTy() && DstTy->isFloatingPointTy()
> &&
>                "Unknown real conversion");
>    -    if (DstTy->getTypeID() < SrcTy->getTypeID())
>    +    int DstId = DstTy->getTypeID();
>    +    int SrcId = Src->getType()->getTypeID();
>    +    if ((SrcId != llvm::Type::HalfTyID && DstId < SrcId) ||
>    +        DstId == llvm::Type::HalfTyID)
>           Res = Builder.CreateFPTrunc(Src, DstTy, "conv");
>         else
>           Res = Builder.CreateFPExt(Src, DstTy, "conv");
Good point!  Removed.

Many thanks,
Anton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: half-clang.patch
Type: application/octet-stream
Size: 16630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120517/14b9afd3/attachment.obj>


More information about the cfe-dev mailing list