[polly] r308649 - Support fabs and copysign in Polly-ACC
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 11:26:34 PDT 2017
Author: grosser
Date: Thu Jul 20 11:26:34 2017
New Revision: 308649
URL: http://llvm.org/viewvc/llvm-project?rev=308649&view=rev
Log:
Support fabs and copysign in Polly-ACC
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=308649&r1=308648&r2=308649&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/PPCGCodeGeneration.cpp Thu Jul 20 11:26:34 2017
@@ -1304,8 +1304,12 @@ isl_bool collectReferencesInGPUStmt(__is
static bool isValidFunctionInKernel(llvm::Function *F) {
assert(F && "F is an invalid pointer");
// We string compare against the name of the function to allow
- // all variants of the intrinsic "llvm.sqrt.*"
- return F->isIntrinsic() && F->getName().startswith("llvm.sqrt");
+ // all variants of the intrinsic "llvm.sqrt.*", "llvm.fabs", and
+ // "llvm.copysign".
+ const StringRef Name = F->getName();
+ return F->isIntrinsic() &&
+ (Name.startswith("llvm.sqrt") || Name.startswith("llvm.fabs") ||
+ Name.startswith("llvm.copysign"));
}
/// 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=308649&r1=308648&r2=308649&view=diff
==============================================================================
--- polly/trunk/test/GPGPU/intrinsic-copied-into-kernel.ll (original)
+++ polly/trunk/test/GPGPU/intrinsic-copied-into-kernel.ll Thu Jul 20 11:26:34 2017
@@ -12,7 +12,8 @@
; Check that the intrinsic call is present in the kernel IR.
; 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) #2
+; KERNEL-IR: declare float @llvm.sqrt.f32(float)
+; KERNEL-IR: declare float @llvm.fabs.f32(float)
; Check that kernel launch is generated in host IR.
; the declare would not be generated unless a call to a kernel exists.
@@ -21,7 +22,11 @@
; void f(float *A, float *B, int N) {
; for(int i = 0; i < N; i++) {
-; B[i] = sqrt(A[i]);
+; float tmp0 = A[i];
+; float tmp1 = sqrt(tmp1);
+; float tmp2 = fabs(tmp2);
+; float tmp3 = copysignf(tmp1, tmp2);
+; B[i] = tmp3;
; }
; }
@@ -42,10 +47,12 @@ for.body:
%indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
%A.arr.i = getelementptr inbounds float, float* %A, i64 %indvars.iv
%A.arr.i.val = load float, float* %A.arr.i, align 4
- ; Call to intrinsic that should be part of the kernel.
+ ; Call to intrinsics that should be part of the kernel.
%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);
%B.arr.i = getelementptr inbounds float, float* %B, i64 %indvars.iv
- store float %sqrt, float* %B.arr.i, align 4
+ store float %copysign, float* %B.arr.i, align 4
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%wide.trip.count = zext i32 %N to i64
@@ -61,6 +68,8 @@ for.end:
; Function Attrs: nounwind readnone
declare float @llvm.sqrt.f32(float) #0
+declare float @llvm.fabs.f32(float) #0
+declare float @llvm.copysign.f32(float, float) #0
attributes #0 = { nounwind readnone }
More information about the llvm-commits
mailing list