[clang] [Clang] Do not emit intrinsic math functions on GPU targets (PR #98209)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 10 01:16:23 PDT 2024
================
@@ -0,0 +1,51 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa %s -emit-llvm -o - | FileCheck %s --check-prefix AMDGPU
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda %s -emit-llvm -o - | FileCheck %s --check-prefix NVPTX
+
+double sin(double);
+double cos(double);
+double sqrt(double);
+
+// AMDGPU-LABEL: define dso_local void @libcalls(
+// AMDGPU-SAME: ) #[[ATTR0:[0-9]+]] {
+// AMDGPU-NEXT: [[ENTRY:.*:]]
+// AMDGPU-NEXT: [[CALL:%.*]] = call double @sin(double noundef 0.000000e+00) #[[ATTR3:[0-9]+]]
+// AMDGPU-NEXT: [[CALL1:%.*]] = call double @cos(double noundef 0.000000e+00) #[[ATTR3]]
+// AMDGPU-NEXT: [[CALL2:%.*]] = call double @sqrt(double noundef 0.000000e+00) #[[ATTR3]]
+// AMDGPU-NEXT: ret void
+//
+// NVPTX-LABEL: define dso_local void @libcalls(
+// NVPTX-SAME: ) #[[ATTR0:[0-9]+]] {
+// NVPTX-NEXT: [[ENTRY:.*:]]
+// NVPTX-NEXT: [[CALL:%.*]] = call double @sin(double noundef 0.000000e+00) #[[ATTR3:[0-9]+]]
+// NVPTX-NEXT: [[CALL1:%.*]] = call double @cos(double noundef 0.000000e+00) #[[ATTR3]]
+// NVPTX-NEXT: [[CALL2:%.*]] = call double @sqrt(double noundef 0.000000e+00) #[[ATTR3]]
+// NVPTX-NEXT: ret void
+//
+void libcalls() {
+ (void)sin(0.);
+ (void)cos(0.);
+ (void)sqrt(0.);
----------------
arsenm wrote:
This test really ought to be comprehensive and test every single math function, and cover the float and double versions
https://github.com/llvm/llvm-project/pull/98209
More information about the cfe-commits
mailing list