[Libclc-dev] [bug-fix] add_sat cannot handle type larger than i8 correctly.

Peter Collingbourne peter at pcc.me.uk
Sun Aug 5 15:31:33 PDT 2012


On Sat, Jun 02, 2012 at 02:31:58PM +0800, Lei Mou wrote:
> Hi Peter,
> 
> Thank you for your work, my work benefit a lot from libclc. During my
> attempt to implement sub_sat, I found a bug in function add_sat. It cannot
> handle arguments larger than char correctly. Here is an example founded in
> builtins.link.bc:
> 
> define ptx_device i64 @_Z7add_satll(i64 %x, i64 %y) nounwind alwaysinline {
> entry:
>   %call = tail call ptx_device i8 bitcast (i64 (i64, i64)*
> @__clc_add_sat_s64 to i8 (i64, i64)*)(i64 %x, i64 %y) nounwind  <-- return
> type of i64 is explicitly converted to i8
>   %conv = sext i8 %call to i64
>   ret i64 %conv
> }
> 
> The bug stems from the declarations in add_sat.cl, where the return type of
> all add_sat function is declared as "char". Here is a patch fixing this bug
> by simply changing the return type of each function declaration to the same
> type as their parameters. Patch for sub_sat will be sent in another mail.
> :-)

Hi Lei,

Sorry that this patch slipped through the cracks, but I've applied
it in r161311.

Thanks,
-- 
Peter




More information about the Libclc-dev mailing list