[polly] r311324 - [GPGPU] Add llvm.powi to the libdevice supported functions

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 02:52:08 PDT 2017


Author: grosser
Date: Mon Aug 21 02:52:08 2017
New Revision: 311324

URL: http://llvm.org/viewvc/llvm-project?rev=311324&view=rev
Log:
[GPGPU] Add llvm.powi to the libdevice supported functions

These intrinsics are used in COSMO.

Modified:
    polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
    polly/trunk/test/GPGPU/intrinsic-copied-into-kernel.ll

Modified: polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp?rev=311324&r1=311323&r2=311324&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Mon Aug 21 02:52:08 2017
@@ -1406,7 +1406,7 @@ static bool isValidFunctionInKernel(llvm
 
   return F->isIntrinsic() &&
          (Name.startswith("llvm.sqrt") || Name.startswith("llvm.fabs") ||
-          Name.startswith("llvm.copysign"));
+          Name.startswith("llvm.copysign") || Name.startswith("llvm.powi"));
 }
 
 /// Do not take `Function` as a subtree value.

Modified: polly/trunk/test/GPGPU/intrinsic-copied-into-kernel.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/GPGPU/intrinsic-copied-into-kernel.ll?rev=311324&r1=311323&r2=311324&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/intrinsic-copied-into-kernel.ll (original)
+++ polly/trunk/test/GPGPU/intrinsic-copied-into-kernel.ll Mon Aug 21 02:52:08 2017
@@ -14,6 +14,7 @@
 ; KERNEL-IR:   %p_sqrt = tail call float @llvm.sqrt.f32(float %A.arr.i.val_p_scalar_)
 ; KERNEL-IR:   declare float @llvm.sqrt.f32(float)
 ; KERNEL-IR:   declare float @llvm.fabs.f32(float)
+; KERNEL-IR:   declare float @llvm.powi.f32(float, i32)
 
 ; Check that kernel launch is generated in host IR.
 ; the declare would not be generated unless a call to a kernel exists.
@@ -26,7 +27,8 @@
 ;       float tmp1 = sqrt(tmp1);
 ;       float tmp2 = fabs(tmp2);
 ;       float tmp3 = copysignf(tmp1, tmp2);
-;       B[i] = tmp3;
+;       float tmp4 = powi(tmp3, 2);
+;       B[i] = tmp4;
 ;   }
 ; }
 
@@ -51,8 +53,9 @@ for.body:
   %sqrt = tail call float @llvm.sqrt.f32(float %A.arr.i.val)
   %fabs = tail call float @llvm.fabs.f32(float %sqrt);
   %copysign = tail call float @llvm.copysign.f32(float %sqrt, float %fabs);
+  %powi = tail call float @llvm.powi.f32(float %copysign, i32 2);
   %B.arr.i = getelementptr inbounds float, float* %B, i64 %indvars.iv
-  store float %copysign, float* %B.arr.i, align 4
+  store float %powi, float* %B.arr.i, align 4
 
   %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
   %wide.trip.count = zext i32 %N to i64
@@ -70,6 +73,7 @@ for.end:
 declare float @llvm.sqrt.f32(float) #0
 declare float @llvm.fabs.f32(float) #0
 declare float @llvm.copysign.f32(float, float) #0
+declare float @llvm.powi.f32(float, i32) #0
 
 attributes #0 = { nounwind readnone }
 




More information about the llvm-commits mailing list