[PATCH] D60907: [OpenMP][WIP] Add math functions support in OpenMP offloading

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 06:58:20 PDT 2019

gtbercea added a comment.

In D60907#1473406 <https://reviews.llvm.org/D60907#1473406>, @Hahnfeld wrote:

> So the scheme is: `pow` is defined in `__clang_openmp_math.h` to call `__kmpc_pow`. This lives in `libomptarget-nvptx` (both bc and static lib) and just calls `pow` which works because `nvcc` and Clang in CUDA mode make sure that the call gets routed into `libdevice`?
> Did you test that something like `pow(d, 2)` is optimized by LLVM to `d * d`? There's a pass doing so (can't recall the name) and from my previous attempts it didn't work well if you hid the function name instead of the known `pow` one.

The transformation was blocked because of a check in optimizePow() this was preventing pow(x,2) from becoming x*x. By adding the pow functions to the TLI the transformation now applies. This has now been fixed. SQRT is eliminated as per usual, no change for that.

  rC Clang



More information about the cfe-commits mailing list