1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-simplifylib < %s | FileCheck %s
4 ; private variant of sincos is defined but marked nobuiltin, so
5 ; introduce a call to the generic one.
7 define float @_Z3sinf(float %x) {
8 ; CHECK-LABEL: define float @_Z3sinf
9 ; CHECK-SAME: (float [[X:%.*]]) {
10 ; CHECK-NEXT: [[RESULT:%.*]] = call float asm "
11 ; CHECK-NEXT: ret float [[RESULT]]
13 %result = call float asm "; $0 = sin($1)","=v,v"(float %x)
17 define float @_Z3cosf(float %x) {
18 ; CHECK-LABEL: define float @_Z3cosf
19 ; CHECK-SAME: (float [[X:%.*]]) {
20 ; CHECK-NEXT: [[RESULT:%.*]] = call float asm "
21 ; CHECK-NEXT: ret float [[RESULT]]
23 %result = call float asm "; $0 = cos($1)","=v,v"(float %x)
27 define float @_Z6sincosfPU3AS5f(float %x, ptr addrspace(5) %ptr) nobuiltin {
28 ; CHECK-LABEL: define float @_Z6sincosfPU3AS5f
29 ; CHECK-SAME: (float [[X:%.*]], ptr addrspace(5) [[PTR:%.*]]) #[[ATTR0:[0-9]+]] {
30 ; CHECK-NEXT: [[RESULT0:%.*]] = call float asm "
31 ; CHECK-NEXT: [[RESULT1:%.*]] = call float asm "
32 ; CHECK-NEXT: store float [[RESULT1]], ptr addrspace(5) [[PTR]], align 4
33 ; CHECK-NEXT: ret float [[RESULT0]]
35 %result0 = call float asm "; $0 = sin($1)","=v,v"(float %x)
36 %result1 = call float asm "; $0 = cos($1)","=v,v"(float %x)
37 store float %result1, ptr addrspace(5) %ptr
41 define float @_Z6sincosfPU3AS0f(float %x, ptr %ptr) {
42 ; CHECK-LABEL: define float @_Z6sincosfPU3AS0f
43 ; CHECK-SAME: (float [[X:%.*]], ptr [[PTR:%.*]]) {
44 ; CHECK-NEXT: [[RESULT0:%.*]] = call float asm "
45 ; CHECK-NEXT: [[RESULT1:%.*]] = call float asm "
46 ; CHECK-NEXT: store float [[RESULT1]], ptr [[PTR]], align 4
47 ; CHECK-NEXT: ret float [[RESULT0]]
49 %result0 = call float asm "; $0 = sin($1)","=v,v"(float %x)
50 %result1 = call float asm "; $0 = cos($1)","=v,v"(float %x)
51 store float %result1, ptr %ptr
55 define void @sincos_f32(float %x, ptr addrspace(1) nocapture writeonly %sin_out, ptr addrspace(1) nocapture writeonly %cos_out) {
56 ; CHECK-LABEL: define void @sincos_f32
57 ; CHECK-SAME: (float [[X:%.*]], ptr addrspace(1) nocapture writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture writeonly [[COS_OUT:%.*]]) {
59 ; CHECK-NEXT: [[__SINCOS_:%.*]] = alloca float, align 4, addrspace(5)
60 ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr addrspace(5) [[__SINCOS_]] to ptr
61 ; CHECK-NEXT: [[TMP1:%.*]] = call contract float @_Z6sincosfPU3AS0f(float [[X]], ptr [[TMP0]])
62 ; CHECK-NEXT: [[TMP2:%.*]] = load float, ptr addrspace(5) [[__SINCOS_]], align 4
63 ; CHECK-NEXT: store float [[TMP1]], ptr addrspace(1) [[SIN_OUT]], align 4
64 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float [[X]])
65 ; CHECK-NEXT: store float [[TMP2]], ptr addrspace(1) [[COS_OUT]], align 4
66 ; CHECK-NEXT: ret void
69 %call = tail call contract float @_Z3sinf(float %x)
70 store float %call, ptr addrspace(1) %sin_out, align 4
71 %call1 = tail call contract float @_Z3cosf(float %x)
72 store float %call1, ptr addrspace(1) %cos_out, align 4