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 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
6 ; sin and cos are already defined in the module but sincos isn't.
8 define float @_Z3sinf(float noundef %x) {
9 ; CHECK-LABEL: define float @_Z3sinf
10 ; CHECK-SAME: (float noundef [[X:%.*]]) {
11 ; CHECK-NEXT: [[RESULT:%.*]] = call float asm "
12 ; CHECK-NEXT: ret float [[RESULT]]
14 %result = call float asm "; $0 = sin($1)","=v,v"(float %x)
18 define float @_Z3cosf(float noundef %x) {
19 ; CHECK-LABEL: define float @_Z3cosf
20 ; CHECK-SAME: (float noundef [[X:%.*]]) {
21 ; CHECK-NEXT: [[RESULT:%.*]] = call float asm "
22 ; CHECK-NEXT: ret float [[RESULT]]
24 %result = call float asm "; $0 = cos($1)","=v,v"(float %x)
28 define <2 x float> @_Z3sinDv2_f(<2 x float> noundef %x) {
29 ; CHECK-LABEL: define <2 x float> @_Z3sinDv2_f
30 ; CHECK-SAME: (<2 x float> noundef [[X:%.*]]) {
31 ; CHECK-NEXT: [[RESULT:%.*]] = call <2 x float> asm "
32 ; CHECK-NEXT: ret <2 x float> [[RESULT]]
34 %result = call <2 x float> asm "; $0 = sin($1)","=v,v"(<2 x float> %x)
35 ret <2 x float> %result
38 define <2 x float> @_Z3cosDv2_f(<2 x float> noundef %x) {
39 ; CHECK-LABEL: define <2 x float> @_Z3cosDv2_f
40 ; CHECK-SAME: (<2 x float> noundef [[X:%.*]]) {
41 ; CHECK-NEXT: [[RESULT:%.*]] = call <2 x float> asm "
42 ; CHECK-NEXT: ret <2 x float> [[RESULT]]
44 %result = call <2 x float> asm "; $0 = cos($1)","=v,v"(<2 x float> %x)
45 ret <2 x float> %result
48 define void @sincos_f32(float noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) {
49 ; CHECK-LABEL: define void @sincos_f32
50 ; CHECK-SAME: (float noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) {
52 ; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float noundef [[X]])
53 ; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4
54 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float noundef [[X]])
55 ; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4
56 ; CHECK-NEXT: ret void
59 %call = tail call contract float @_Z3sinf(float noundef %x)
60 store float %call, ptr addrspace(1) %sin_out, align 4
61 %call1 = tail call contract float @_Z3cosf(float noundef %x)
62 store float %call1, ptr addrspace(1) %cos_out, align 4
66 define void @sincos_f32_value_is_same_constantfp(ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) {
67 ; CHECK-LABEL: define void @sincos_f32_value_is_same_constantfp
68 ; CHECK-SAME: (ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) {
70 ; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float 4.200000e+01)
71 ; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4
72 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float 4.200000e+01)
73 ; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4
74 ; CHECK-NEXT: ret void
77 %call = tail call contract float @_Z3sinf(float 42.0)
78 store float %call, ptr addrspace(1) %sin_out, align 4
79 %call1 = tail call contract float @_Z3cosf(float 42.0)
80 store float %call1, ptr addrspace(1) %cos_out, align 4
84 define void @sincos_v2f32(<2 x float> noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) {
85 ; GCN-LABEL: define void @sincos_v2f32
86 ; GCN-SAME: (<2 x float> noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) local_unnamed_addr {
88 ; GCN-NEXT: [[CALL:%.*]] = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> noundef [[X]])
89 ; GCN-NEXT: store <2 x float> [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 8
90 ; GCN-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef [[X]])
91 ; GCN-NEXT: store <2 x float> [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 8
94 ; CHECK-LABEL: define void @sincos_v2f32
95 ; CHECK-SAME: (<2 x float> noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) {
97 ; CHECK-NEXT: [[CALL:%.*]] = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> noundef [[X]])
98 ; CHECK-NEXT: store <2 x float> [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 8
99 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef [[X]])
100 ; CHECK-NEXT: store <2 x float> [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 8
101 ; CHECK-NEXT: ret void
104 %call = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> noundef %x)
105 store <2 x float> %call, ptr addrspace(1) %sin_out, align 8
106 %call1 = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef %x)
107 store <2 x float> %call1, ptr addrspace(1) %cos_out, align 8