1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals --version 2
2 ; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-simplifylib -amdgpu-prelink < %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 declare float @_Z3sinf(float noundef)
7 declare float @_Z3cosf(float noundef)
8 declare <2 x float> @_Z3sinDv2_f(<2 x float> noundef)
9 declare <2 x float> @_Z3cosDv2_f(<2 x float> noundef)
11 define void @sincos_f32_nobuiltin(float noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) #0 {
12 ; CHECK: Function Attrs: nobuiltin
13 ; CHECK-LABEL: define void @sincos_f32_nobuiltin
14 ; CHECK-SAME: (float noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) #[[ATTR0:[0-9]+]] {
16 ; CHECK-NEXT: [[__SINCOS_:%.*]] = alloca float, align 4, addrspace(5)
17 ; CHECK-NEXT: [[TMP0:%.*]] = call contract float @_Z6sincosfPU3AS5f(float [[X]], ptr addrspace(5) [[__SINCOS_]])
18 ; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(5) [[__SINCOS_]], align 4
19 ; CHECK-NEXT: store float [[TMP0]], ptr addrspace(1) [[SIN_OUT]], align 4
20 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float noundef [[X]])
21 ; CHECK-NEXT: store float [[TMP1]], ptr addrspace(1) [[COS_OUT]], align 4
22 ; CHECK-NEXT: ret void
25 %call = tail call contract float @_Z3sinf(float noundef %x)
26 store float %call, ptr addrspace(1) %sin_out, align 4
27 %call1 = tail call contract float @_Z3cosf(float noundef %x)
28 store float %call1, ptr addrspace(1) %cos_out, align 4
32 define void @sincos_v2f32_nobuiltin(<2 x float> noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) #0 {
33 ; CHECK: Function Attrs: nobuiltin
34 ; CHECK-LABEL: define void @sincos_v2f32_nobuiltin
35 ; CHECK-SAME: (<2 x float> noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) #[[ATTR0]] {
37 ; CHECK-NEXT: [[__SINCOS_:%.*]] = alloca <2 x float>, align 8, addrspace(5)
38 ; CHECK-NEXT: [[TMP0:%.*]] = call contract <2 x float> @_Z6sincosDv2_fPU3AS5S_(<2 x float> [[X]], ptr addrspace(5) [[__SINCOS_]])
39 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x float>, ptr addrspace(5) [[__SINCOS_]], align 8
40 ; CHECK-NEXT: store <2 x float> [[TMP0]], ptr addrspace(1) [[SIN_OUT]], align 8
41 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef [[X]])
42 ; CHECK-NEXT: store <2 x float> [[TMP1]], ptr addrspace(1) [[COS_OUT]], align 8
43 ; CHECK-NEXT: ret void
46 %call = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> noundef %x)
47 store <2 x float> %call, ptr addrspace(1) %sin_out, align 8
48 %call1 = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef %x)
49 store <2 x float> %call1, ptr addrspace(1) %cos_out, align 8
53 define void @sincos_f32_no_builtins(float noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) #1 {
54 ; CHECK-LABEL: define void @sincos_f32_no_builtins
55 ; CHECK-SAME: (float noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) #[[ATTR1:[0-9]+]] {
57 ; CHECK-NEXT: [[__SINCOS_:%.*]] = alloca float, align 4, addrspace(5)
58 ; CHECK-NEXT: [[TMP0:%.*]] = call contract float @_Z6sincosfPU3AS5f(float [[X]], ptr addrspace(5) [[__SINCOS_]])
59 ; CHECK-NEXT: [[TMP1:%.*]] = load float, ptr addrspace(5) [[__SINCOS_]], align 4
60 ; CHECK-NEXT: store float [[TMP0]], ptr addrspace(1) [[SIN_OUT]], align 4
61 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float noundef [[X]])
62 ; CHECK-NEXT: store float [[TMP1]], ptr addrspace(1) [[COS_OUT]], align 4
63 ; CHECK-NEXT: ret void
66 %call = tail call contract float @_Z3sinf(float noundef %x)
67 store float %call, ptr addrspace(1) %sin_out, align 4
68 %call1 = tail call contract float @_Z3cosf(float noundef %x)
69 store float %call1, ptr addrspace(1) %cos_out, align 4
73 define void @sincos_v2f32_no_builtins(<2 x float> noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) #1 {
74 ; CHECK-LABEL: define void @sincos_v2f32_no_builtins
75 ; CHECK-SAME: (<2 x float> noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) #[[ATTR1]] {
77 ; CHECK-NEXT: [[__SINCOS_:%.*]] = alloca <2 x float>, align 8, addrspace(5)
78 ; CHECK-NEXT: [[TMP0:%.*]] = call contract <2 x float> @_Z6sincosDv2_fPU3AS5S_(<2 x float> [[X]], ptr addrspace(5) [[__SINCOS_]])
79 ; CHECK-NEXT: [[TMP1:%.*]] = load <2 x float>, ptr addrspace(5) [[__SINCOS_]], align 8
80 ; CHECK-NEXT: store <2 x float> [[TMP0]], ptr addrspace(1) [[SIN_OUT]], align 8
81 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef [[X]])
82 ; CHECK-NEXT: store <2 x float> [[TMP1]], ptr addrspace(1) [[COS_OUT]], align 8
83 ; CHECK-NEXT: ret void
86 %call = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> noundef %x)
87 store <2 x float> %call, ptr addrspace(1) %sin_out, align 8
88 %call1 = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef %x)
89 store <2 x float> %call1, ptr addrspace(1) %cos_out, align 8
93 define void @sincos_f32_nobuiltin_callsite(float noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) {
94 ; CHECK-LABEL: define void @sincos_f32_nobuiltin_callsite
95 ; CHECK-SAME: (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 float @_Z3sinf(float noundef [[X]]) #[[ATTR0]]
98 ; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4
99 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float noundef [[X]]) #[[ATTR0]]
100 ; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4
101 ; CHECK-NEXT: ret void
104 %call = tail call contract float @_Z3sinf(float noundef %x) #0
105 store float %call, ptr addrspace(1) %sin_out, align 4
106 %call1 = tail call contract float @_Z3cosf(float noundef %x) #0
107 store float %call1, ptr addrspace(1) %cos_out, align 4
111 define void @sincos_f32_nobuiltin_callsite0(float noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) {
112 ; CHECK-LABEL: define void @sincos_f32_nobuiltin_callsite0
113 ; CHECK-SAME: (float noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) {
115 ; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float noundef [[X]]) #[[ATTR0]]
116 ; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4
117 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float noundef [[X]])
118 ; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4
119 ; CHECK-NEXT: ret void
122 %call = tail call contract float @_Z3sinf(float noundef %x) #0
123 store float %call, ptr addrspace(1) %sin_out, align 4
124 %call1 = tail call contract float @_Z3cosf(float noundef %x)
125 store float %call1, ptr addrspace(1) %cos_out, align 4
129 define void @sincos_f32_nobuiltin_callsite1(float noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) {
130 ; CHECK-LABEL: define void @sincos_f32_nobuiltin_callsite1
131 ; CHECK-SAME: (float noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) {
133 ; CHECK-NEXT: [[CALL:%.*]] = tail call contract float @_Z3sinf(float noundef [[X]])
134 ; CHECK-NEXT: store float [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 4
135 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract float @_Z3cosf(float noundef [[X]]) #[[ATTR0]]
136 ; CHECK-NEXT: store float [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 4
137 ; CHECK-NEXT: ret void
140 %call = tail call contract float @_Z3sinf(float noundef %x)
141 store float %call, ptr addrspace(1) %sin_out, align 4
142 %call1 = tail call contract float @_Z3cosf(float noundef %x) #0
143 store float %call1, ptr addrspace(1) %cos_out, align 4
147 define void @sincos_v2f32_nobuiltin_callsite(<2 x float> noundef %x, ptr addrspace(1) nocapture noundef writeonly %sin_out, ptr addrspace(1) nocapture noundef writeonly %cos_out) {
148 ; CHECK-LABEL: define void @sincos_v2f32_nobuiltin_callsite
149 ; CHECK-SAME: (<2 x float> noundef [[X:%.*]], ptr addrspace(1) nocapture noundef writeonly [[SIN_OUT:%.*]], ptr addrspace(1) nocapture noundef writeonly [[COS_OUT:%.*]]) {
151 ; CHECK-NEXT: [[CALL:%.*]] = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> noundef [[X]]) #[[ATTR0]]
152 ; CHECK-NEXT: store <2 x float> [[CALL]], ptr addrspace(1) [[SIN_OUT]], align 8
153 ; CHECK-NEXT: [[CALL1:%.*]] = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef [[X]]) #[[ATTR0]]
154 ; CHECK-NEXT: store <2 x float> [[CALL1]], ptr addrspace(1) [[COS_OUT]], align 8
155 ; CHECK-NEXT: ret void
158 %call = tail call contract <2 x float> @_Z3sinDv2_f(<2 x float> noundef %x) #0
159 store <2 x float> %call, ptr addrspace(1) %sin_out, align 8
160 %call1 = tail call contract <2 x float> @_Z3cosDv2_f(<2 x float> noundef %x) #0
161 store <2 x float> %call1, ptr addrspace(1) %cos_out, align 8
165 ; TODO: Handle single function forms
166 attributes #0 = { nobuiltin }
167 attributes #1 = { "no-builtins" }
169 ; CHECK: attributes #[[ATTR0]] = { nobuiltin }
170 ; CHECK: attributes #[[ATTR1]] = { "no-builtins" }