71 lines · plain
1; RUN: llc < %s | FileCheck %s2 3; This test is reduced from https://github.com/llvm/llvm-project/issues/140491.4; It checks that when `@llvm.sincos.f32` is expanded to a call to5; `sincosf(float, float* out_sin, float* out_cos)` and the store of `%cos` to6; `%computed` is folded into the `sincosf` call. The use of `%cos`in the later7; `fneg %cos` -- which expands to a load of `%computed`, will perform the load8; before the `@llvm.lifetime.end.p0(%computed)` to ensure the correct value is9; taken for `%cos`.10 11target triple = "x86_64-sie-ps5"12 13declare void @use_ptr(ptr readonly)14 15define i32 @sincos_stack_slot_with_lifetime(float %in) {16; CHECK-LABEL: sincos_stack_slot_with_lifetime:17; CHECK: # %bb.0: # %entry18; CHECK-NEXT: pushq %rbx19; CHECK-NEXT: .cfi_def_cfa_offset 1620; CHECK-NEXT: subq $32, %rsp21; CHECK-NEXT: .cfi_def_cfa_offset 4822; CHECK-NEXT: .cfi_offset %rbx, -1623; CHECK-NEXT: leaq 12(%rsp), %rdi24; CHECK-NEXT: leaq 8(%rsp), %rbx25; CHECK-NEXT: movq %rbx, %rsi26; CHECK-NEXT: callq sincosf@PLT27; CHECK-NEXT: movss 8(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero28; CHECK-NEXT: movaps %xmm0, 16(%rsp) # 16-byte Spill29; CHECK-NEXT: movq %rbx, %rdi30; CHECK-NEXT: callq use_ptr31; CHECK-NEXT: movss 12(%rsp), %xmm0 # xmm0 = mem[0],zero,zero,zero32; CHECK-NEXT: xorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm033; CHECK-NEXT: movss %xmm0, 8(%rsp)34; CHECK-NEXT: leaq 8(%rsp), %rdi35; CHECK-NEXT: callq use_ptr36; CHECK-NEXT: movaps 16(%rsp), %xmm0 # 16-byte Reload37; CHECK-NEXT: xorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm038; CHECK-NEXT: movss %xmm0, 8(%rsp)39; CHECK-NEXT: leaq 8(%rsp), %rdi40; CHECK-NEXT: callq use_ptr41; CHECK-NEXT: xorl %eax, %eax42; CHECK-NEXT: addq $32, %rsp43; CHECK-NEXT: .cfi_def_cfa_offset 1644; CHECK-NEXT: popq %rbx45; CHECK-NEXT: .cfi_def_cfa_offset 846; CHECK-NEXT: retq47entry:48 %computed = alloca float, align 449 %computed1 = alloca float, align 450 %computed3 = alloca float, align 451 %sincos = tail call { float, float } @llvm.sincos.f32(float %in)52 %sin = extractvalue { float, float } %sincos, 053 %cos = extractvalue { float, float } %sincos, 154 call void @llvm.lifetime.start.p0(ptr nonnull %computed)55 store float %cos, ptr %computed, align 456 call void @use_ptr(ptr nonnull %computed)57 call void @llvm.lifetime.end.p0(ptr nonnull %computed)58 call void @llvm.lifetime.start.p0(ptr nonnull %computed1)59 %fneg_sin = fneg float %sin60 store float %fneg_sin, ptr %computed1, align 461 call void @use_ptr(ptr nonnull %computed1)62 call void @llvm.lifetime.end.p0(ptr nonnull %computed1)63 call void @llvm.lifetime.start.p0(ptr nonnull %computed3)64 %fneg_cos = fneg float %cos65 store float %fneg_cos, ptr %computed3, align 466 call void @use_ptr(ptr nonnull %computed3)67 call void @llvm.lifetime.end.p0(ptr nonnull %computed3)68 ret i32 069}70 71