1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=aarch64-linux-gnu -o - %s | FileCheck %s
; This file tests eliding stack slots when lowering the FSINCOS ISD node.
define { float, float } @sincos_f32_value_return(float %x) {
; CHECK-LABEL: sincos_f32_value_return:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: add x0, sp, #12
; CHECK-NEXT: add x1, sp, #8
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldp s1, s0, [sp, #8]
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call float @llvm.sin.f32(float %x)
%cos = tail call float @llvm.cos.f32(float %x)
%ret_0 = insertvalue { float, float } poison, float %sin, 0
%ret_1 = insertvalue { float, float } %ret_0, float %cos, 1
ret { float, float } %ret_1
}
define void @sincos_f32_ptr_return(float %x, ptr noalias %out_sin, ptr noalias %out_cos) {
; CHECK-LABEL: sincos_f32_ptr_return:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call float @llvm.sin.f32(float %x)
%cos = tail call float @llvm.cos.f32(float %x)
store float %sin, ptr %out_sin, align 4
store float %cos, ptr %out_cos, align 4
ret void
}
define float @sincos_f32_mixed_return(float %x, ptr %out_sin) {
; CHECK-LABEL: sincos_f32_mixed_return:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: add x1, sp, #12
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldr s0, [sp, #12]
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call float @llvm.sin.f32(float %x)
%cos = tail call float @llvm.cos.f32(float %x)
store float %sin, ptr %out_sin, align 4
ret float %cos
}
define { double, double } @sincos_f64_value_return(double %x) {
; CHECK-LABEL: sincos_f64_value_return:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: sub sp, sp, #32
; CHECK-NEXT: str x30, [sp, #16] // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 32
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: add x0, sp, #24
; CHECK-NEXT: add x1, sp, #8
; CHECK-NEXT: bl sincos
; CHECK-NEXT: ldr d0, [sp, #24]
; CHECK-NEXT: ldr d1, [sp, #8]
; CHECK-NEXT: ldr x30, [sp, #16] // 8-byte Folded Reload
; CHECK-NEXT: add sp, sp, #32
; CHECK-NEXT: ret
entry:
%sin = tail call double @llvm.sin.f64(double %x)
%cos = tail call double @llvm.cos.f64(double %x)
%ret_0 = insertvalue { double, double } poison, double %sin, 0
%ret_1 = insertvalue { double, double } %ret_0, double %cos, 1
ret { double, double } %ret_1
}
define void @sincos_f64_ptr_return(double %x, ptr noalias %out_sin, ptr noalias %out_cos) {
; CHECK-LABEL: sincos_f64_ptr_return:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: bl sincos
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call double @llvm.sin.f64(double %x)
%cos = tail call double @llvm.cos.f64(double %x)
store double %sin, ptr %out_sin, align 8
store double %cos, ptr %out_cos, align 8
ret void
}
define double @sincos_f64_mixed_return(double %x, ptr %out_sin) {
; CHECK-LABEL: sincos_f64_mixed_return:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: add x1, sp, #8
; CHECK-NEXT: bl sincos
; CHECK-NEXT: ldr d0, [sp, #8]
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call double @llvm.sin.f64(double %x)
%cos = tail call double @llvm.cos.f64(double %x)
store double %sin, ptr %out_sin, align 8
ret double %cos
}
; Here %out_sin and %out_cos may alias so we can't replace both stores with the
; call to sincosf (as the order of stores in sincosf is not defined).
define void @sincos_may_alias(float %x, ptr %out_sin, ptr %out_cos) {
; CHECK-LABEL: sincos_may_alias:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: sub sp, sp, #32
; CHECK-NEXT: stp x30, x19, [sp, #16] // 16-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 32
; CHECK-NEXT: .cfi_offset w19, -8
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: mov x19, x1
; CHECK-NEXT: add x1, sp, #12
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldr s0, [sp, #12]
; CHECK-NEXT: str s0, [x19]
; CHECK-NEXT: ldp x30, x19, [sp, #16] // 16-byte Folded Reload
; CHECK-NEXT: add sp, sp, #32
; CHECK-NEXT: ret
entry:
%sin = tail call float @llvm.sin.f32(float %x)
%cos = tail call float @llvm.cos.f32(float %x)
store float %sin, ptr %out_sin, align 4
store float %cos, ptr %out_cos, align 4
ret void
}
; Here %out is used for both sin and cos (with the final value stored being cos).
define float @sincos_multiple_uses(float %x, ptr %out) {
; CHECK-LABEL: sincos_multiple_uses:
; CHECK: // %bb.0:
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: .cfi_offset w30, -16
; CHECK-NEXT: mov x1, x0
; CHECK-NEXT: add x0, sp, #12
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldr s0, [sp, #12]
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
; CHECK-NEXT: ret
%sin = call float @llvm.sin.f32(float %x)
store float %sin, ptr %out, align 4
%reload = load float, ptr %out, align 4
%cos = call float @llvm.cos.f32(float %x)
store float %cos, ptr %out, align 4
ret float %reload
}
; Negative test. We can't fold volatile stores into the library call.
define void @sincos_volatile_result_stores(float %x, ptr noalias %out_sin, ptr noalias %out_cos) {
; CHECK-LABEL: sincos_volatile_result_stores:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill
; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 32
; CHECK-NEXT: .cfi_offset w19, -8
; CHECK-NEXT: .cfi_offset w20, -16
; CHECK-NEXT: .cfi_offset w30, -32
; CHECK-NEXT: mov x19, x1
; CHECK-NEXT: mov x20, x0
; CHECK-NEXT: add x0, sp, #12
; CHECK-NEXT: add x1, sp, #8
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldp s1, s0, [sp, #8]
; CHECK-NEXT: str s0, [x20]
; CHECK-NEXT: str s1, [x19]
; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload
; CHECK-NEXT: ldr x30, [sp], #32 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call float @llvm.sin.f32(float %x)
%cos = tail call float @llvm.cos.f32(float %x)
store volatile float %sin, ptr %out_sin, align 4
store volatile float %cos, ptr %out_cos, align 4
ret void
}
; Negative test. We can't fold atomic stores into the library call.
define void @sincos_atomic_result_stores(float %x, ptr noalias %out_sin, ptr noalias %out_cos) {
; CHECK-LABEL: sincos_atomic_result_stores:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill
; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 32
; CHECK-NEXT: .cfi_offset w19, -8
; CHECK-NEXT: .cfi_offset w20, -16
; CHECK-NEXT: .cfi_offset w30, -32
; CHECK-NEXT: mov x19, x1
; CHECK-NEXT: mov x20, x0
; CHECK-NEXT: add x0, sp, #12
; CHECK-NEXT: add x1, sp, #8
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldr w8, [sp, #12]
; CHECK-NEXT: str w8, [x20]
; CHECK-NEXT: ldr w8, [sp, #8]
; CHECK-NEXT: str w8, [x19]
; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload
; CHECK-NEXT: ldr x30, [sp], #32 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call float @llvm.sin.f32(float %x)
%cos = tail call float @llvm.cos.f32(float %x)
store atomic float %sin, ptr %out_sin unordered, align 4
store atomic float %cos, ptr %out_cos unordered, align 4
ret void
}
; Negative test. We can't fold misaligned stores into the library call.
define void @sincos_misaligned_result_stores(double %x, ptr noalias %out_sin, ptr noalias %out_cos) {
; CHECK-LABEL: sincos_misaligned_result_stores:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: sub sp, sp, #48
; CHECK-NEXT: str x30, [sp, #16] // 8-byte Folded Spill
; CHECK-NEXT: stp x20, x19, [sp, #32] // 16-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 48
; CHECK-NEXT: .cfi_offset w19, -8
; CHECK-NEXT: .cfi_offset w20, -16
; CHECK-NEXT: .cfi_offset w30, -32
; CHECK-NEXT: mov x19, x1
; CHECK-NEXT: mov x20, x0
; CHECK-NEXT: add x0, sp, #24
; CHECK-NEXT: add x1, sp, #8
; CHECK-NEXT: bl sincos
; CHECK-NEXT: ldr d0, [sp, #24]
; CHECK-NEXT: ldr d1, [sp, #8]
; CHECK-NEXT: ldr x30, [sp, #16] // 8-byte Folded Reload
; CHECK-NEXT: str d0, [x20]
; CHECK-NEXT: str d1, [x19]
; CHECK-NEXT: ldp x20, x19, [sp, #32] // 16-byte Folded Reload
; CHECK-NEXT: add sp, sp, #48
; CHECK-NEXT: ret
entry:
%sin = tail call double @llvm.sin.f64(double %x)
%cos = tail call double @llvm.cos.f64(double %x)
store double %sin, ptr %out_sin, align 4
store double %cos, ptr %out_cos, align 4
ret void
}
declare void @foo(ptr, ptr)
define void @can_fold_with_call_in_chain(float %x, ptr noalias %a, ptr noalias %b) {
; CHECK-LABEL: can_fold_with_call_in_chain:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: str d8, [sp, #-32]! // 8-byte Folded Spill
; CHECK-NEXT: str x30, [sp, #8] // 8-byte Folded Spill
; CHECK-NEXT: stp x20, x19, [sp, #16] // 16-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 32
; CHECK-NEXT: .cfi_offset w19, -8
; CHECK-NEXT: .cfi_offset w20, -16
; CHECK-NEXT: .cfi_offset w30, -24
; CHECK-NEXT: .cfi_offset b8, -32
; CHECK-NEXT: mov x19, x1
; CHECK-NEXT: mov x20, x0
; CHECK-NEXT: fmov s8, s0
; CHECK-NEXT: bl foo
; CHECK-NEXT: fmov s0, s8
; CHECK-NEXT: mov x0, x20
; CHECK-NEXT: mov x1, x19
; CHECK-NEXT: bl sincosf
; CHECK-NEXT: ldp x20, x19, [sp, #16] // 16-byte Folded Reload
; CHECK-NEXT: ldr x30, [sp, #8] // 8-byte Folded Reload
; CHECK-NEXT: ldr d8, [sp], #32 // 8-byte Folded Reload
; CHECK-NEXT: ret
entry:
%sin = tail call float @llvm.sin.f32(float %x)
%cos = tail call float @llvm.cos.f32(float %x)
call void @foo(ptr %a, ptr %b)
store float %sin, ptr %a, align 4
store float %cos, ptr %b, align 4
ret void
}
|