|
23 | 23 | ret { float, float } %ret_1
|
24 | 24 | }
|
25 | 25 |
|
26 |
| -define void @sincos_f32_ptr_return(float %x, ptr %out_sin, ptr %out_cos) { |
| 26 | +define void @sincos_f32_ptr_return(float %x, ptr noalias %out_sin, ptr noalias %out_cos) { |
27 | 27 | ; CHECK-LABEL: sincos_f32_ptr_return:
|
28 | 28 | ; CHECK: // %bb.0: // %entry
|
29 | 29 | ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
|
|
81 | 81 | ret { double, double } %ret_1
|
82 | 82 | }
|
83 | 83 |
|
84 |
| -define void @sincos_f64_ptr_return(double %x, ptr %out_sin, ptr %out_cos) { |
| 84 | +define void @sincos_f64_ptr_return(double %x, ptr noalias %out_sin, ptr noalias %out_cos) { |
85 | 85 | ; CHECK-LABEL: sincos_f64_ptr_return:
|
86 | 86 | ; CHECK: // %bb.0: // %entry
|
87 | 87 | ; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
|
@@ -116,8 +116,55 @@ entry:
|
116 | 116 | ret double %cos
|
117 | 117 | }
|
118 | 118 |
|
| 119 | +; Here %out_sin and %out_cos may alias so we can't replace both stores with the |
| 120 | +; call to sincosf (as the order of stores in sincosf is not defined). |
| 121 | +define void @sincos_may_alias(float %x, ptr %out_sin, ptr %out_cos) { |
| 122 | +; CHECK-LABEL: sincos_may_alias: |
| 123 | +; CHECK: // %bb.0: // %entry |
| 124 | +; CHECK-NEXT: sub sp, sp, #32 |
| 125 | +; CHECK-NEXT: stp x30, x19, [sp, #16] // 16-byte Folded Spill |
| 126 | +; CHECK-NEXT: .cfi_def_cfa_offset 32 |
| 127 | +; CHECK-NEXT: .cfi_offset w19, -8 |
| 128 | +; CHECK-NEXT: .cfi_offset w30, -16 |
| 129 | +; CHECK-NEXT: mov x19, x1 |
| 130 | +; CHECK-NEXT: add x1, sp, #12 |
| 131 | +; CHECK-NEXT: bl sincosf |
| 132 | +; CHECK-NEXT: ldr s0, [sp, #12] |
| 133 | +; CHECK-NEXT: str s0, [x19] |
| 134 | +; CHECK-NEXT: ldp x30, x19, [sp, #16] // 16-byte Folded Reload |
| 135 | +; CHECK-NEXT: add sp, sp, #32 |
| 136 | +; CHECK-NEXT: ret |
| 137 | +entry: |
| 138 | + %sin = tail call float @llvm.sin.f32(float %x) |
| 139 | + %cos = tail call float @llvm.cos.f32(float %x) |
| 140 | + store float %sin, ptr %out_sin, align 4 |
| 141 | + store float %cos, ptr %out_cos, align 4 |
| 142 | + ret void |
| 143 | +} |
| 144 | + |
| 145 | +; Here %out is used for both sin and cos (with the final value stored being cos). |
| 146 | +define float @sincos_multiple_uses(float %x, ptr %out) { |
| 147 | +; CHECK-LABEL: sincos_multiple_uses: |
| 148 | +; CHECK: // %bb.0: |
| 149 | +; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill |
| 150 | +; CHECK-NEXT: .cfi_def_cfa_offset 16 |
| 151 | +; CHECK-NEXT: .cfi_offset w30, -16 |
| 152 | +; CHECK-NEXT: mov x1, x0 |
| 153 | +; CHECK-NEXT: add x0, sp, #12 |
| 154 | +; CHECK-NEXT: bl sincosf |
| 155 | +; CHECK-NEXT: ldr s0, [sp, #12] |
| 156 | +; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload |
| 157 | +; CHECK-NEXT: ret |
| 158 | + %sin = call float @llvm.sin.f32(float %x) |
| 159 | + store float %sin, ptr %out, align 4 |
| 160 | + %reload = load float, ptr %out, align 4 |
| 161 | + %cos = call float @llvm.cos.f32(float %x) |
| 162 | + store float %cos, ptr %out, align 4 |
| 163 | + ret float %reload |
| 164 | +} |
| 165 | + |
119 | 166 | ; Negative test. We can't fold volatile stores into the library call.
|
120 |
| -define void @sincos_volatile_result_stores(float %x, ptr %out_sin, ptr %out_cos) { |
| 167 | +define void @sincos_volatile_result_stores(float %x, ptr noalias %out_sin, ptr noalias %out_cos) { |
121 | 168 | ; CHECK-LABEL: sincos_volatile_result_stores:
|
122 | 169 | ; CHECK: // %bb.0: // %entry
|
123 | 170 | ; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill
|
@@ -146,7 +193,7 @@ entry:
|
146 | 193 | }
|
147 | 194 |
|
148 | 195 | ; Negative test. We can't fold atomic stores into the library call.
|
149 |
| -define void @sincos_atomic_result_stores(float %x, ptr %out_sin, ptr %out_cos) { |
| 196 | +define void @sincos_atomic_result_stores(float %x, ptr noalias %out_sin, ptr noalias %out_cos) { |
150 | 197 | ; CHECK-LABEL: sincos_atomic_result_stores:
|
151 | 198 | ; CHECK: // %bb.0: // %entry
|
152 | 199 | ; CHECK-NEXT: str x30, [sp, #-32]! // 8-byte Folded Spill
|
@@ -176,7 +223,7 @@ entry:
|
176 | 223 | }
|
177 | 224 |
|
178 | 225 | ; Negative test. We can't fold misaligned stores into the library call.
|
179 |
| -define void @sincos_misaligned_result_stores(double %x, ptr %out_sin, ptr %out_cos) { |
| 226 | +define void @sincos_misaligned_result_stores(double %x, ptr noalias %out_sin, ptr noalias %out_cos) { |
180 | 227 | ; CHECK-LABEL: sincos_misaligned_result_stores:
|
181 | 228 | ; CHECK: // %bb.0: // %entry
|
182 | 229 | ; CHECK-NEXT: sub sp, sp, #48
|
|
0 commit comments