<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'><font size="3">Dear all,</font><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; "><br></div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">I have been trying to add support for fabs() to libclc and later to the LLVM-PTX backend.</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">This looked simple enough, but I am having trouble starting with the libclc part. I have added</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">the following files:</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; "><br></div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">generic/include/clc/math/fabs.h ---------------------------</div><div><div>#undef fabs</div><div>#define fabs __clc_fabs</div><div><br></div><div>#define FUNCTION __clc_fabs</div><div>#define INTRINSIC "llvm.fabs"</div><div>#include <clc/math/unary_intrin.inc></div></div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">----------------------------------------------------------</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; "><br></div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">generic/include/clc/math/native_fabs.h--------------------</div><div><div>#define native_fabs abs</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">----------------------------------------------------------</div></div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; "><br></div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">And I have added those files to generic/include/clc/clc.h. I expected this to generate</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">@llvm.fabs.[f32/f64] functions as happens for sqrt, for instance. However, I find that the</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; ">definition is already different in LLVM IR:</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; "><br></div><div><div>declare ptx_device double @llvm.fabs.f64(double)</div><div>declare double @llvm.sqrt.f64(double) nounwind readonly</div><div><br></div><div>Since I am unable to get LLVM to lower calls to llvm.fabs as "abs" instructions rather than</div><div>"call.uni", I suspect the declaration differences to be (at least in part) the culprit. Could someone</div><div>point me out in the right direction?</div><div><br></div><div>Thanks in advance,</div><div>Gabriel</div><div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 12pt; "><br></div></div></div></body></html>