Hi Peter,<br><br>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:<div>




<div><br></div><div><div>define ptx_device i64 @_Z7add_satll(i64 %x, i64 %y) nounwind alwaysinline {</div><div>entry:</div><div>  %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</div>




<div>  %conv = sext i8 %call to i64</div><div>  ret i64 %conv</div><div>}</div><div><br></div><div>The bug stems from the declarations in <a href="http://add_sat.cl/" target="_blank">add_sat.cl</a>, 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. :-)</div>



<div><br></div><div>Regards,<br>Lei Mou</div></div></div>