Index: lib/Analysis/TargetLibraryInfo.cpp =================================================================== --- lib/Analysis/TargetLibraryInfo.cpp +++ lib/Analysis/TargetLibraryInfo.cpp @@ -114,6 +114,12 @@ TLI.setUnavailable(LibFunc_log10); TLI.setUnavailable(LibFunc_log10f); TLI.setUnavailable(LibFunc_log10l); + // For PAL OS, we do not have a tan function. + if (T.getOS() == Triple::AMDPAL) { + TLI.setUnavailable(LibFunc_tan); + TLI.setUnavailable(LibFunc_tanf); + TLI.setUnavailable(LibFunc_tanl); + } } // There are no library implementations of memcpy and memset for AMD gpus and Index: test/Transforms/InstCombine/AMDGPU/tan.ll =================================================================== --- /dev/null +++ test/Transforms/InstCombine/AMDGPU/tan.ll @@ -0,0 +1,21 @@ +; RUN: opt -mtriple=amdgcn--amdpal -S -instcombine <%s | FileCheck --check-prefixes=GCN,GCNPAL %s +; RUN: opt -mtriple=amdgcn-- -S -instcombine <%s | FileCheck --check-prefixes=GCN,GCNOTHER %s + +; GCN-LABEL: define amdgpu_ps float @llpc.shader.FS.main +; GCNPAL: call float @llvm.sin.f32 +; GCNPAL: call float @llvm.cos.f32 +; GCNOTHER: call {{.*}} @tanf(float + +declare float @llvm.sin.f32(float) #0 +declare float @llvm.cos.f32(float) #0 + +define amdgpu_ps float @llpc.shader.FS.main(float %arg) { +.entry: + %tmp32 = call float @llvm.sin.f32(float %arg) + %tmp33 = call float @llvm.cos.f32(float %arg) + %tmp34 = fdiv reassoc nnan nsz arcp contract float 1.000000e+00, %tmp33 + %tmp35 = fmul reassoc nnan nsz arcp contract float %tmp32, %tmp34 + ret float %tmp35 +} + +attributes #0 = { nounwind readnone speculatable willreturn }