1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-windows-gnu -exception-model=dwarf < %s | FileCheck %s
3
4%struct.A = type { [4096 x i8] }
5
6@a = common global i32 0, align 4
7@b = common global i32 0, align 4
8
9define void @fn1() nounwind uwtable {
10; CHECK-LABEL: fn1:
11; CHECK:       # %bb.0: # %entry
12; CHECK-NEXT:    movl $4136, %eax # imm = 0x1028
13; CHECK-NEXT:    callq ___chkstk_ms
14; CHECK-NEXT:    subq %rax, %rsp
15; CHECK-NEXT:    .cfi_def_cfa_offset 4144
16; CHECK-NEXT:    movl {{.*}}(%rip), %eax
17; CHECK-NEXT:    testl %eax, %eax
18; CHECK-NEXT:    jne .LBB0_2
19; CHECK-NEXT:  # %bb.1: # %select.true.sink
20; CHECK-NEXT:    cltq
21; CHECK-NEXT:    imulq $715827883, %rax, %rax # imm = 0x2AAAAAAB
22; CHECK-NEXT:    movq %rax, %rcx
23; CHECK-NEXT:    shrq $63, %rcx
24; CHECK-NEXT:    shrq $32, %rax
25; CHECK-NEXT:    addl %ecx, %eax
26; CHECK-NEXT:  .LBB0_2: # %select.end
27; CHECK-NEXT:    movl %eax, {{.*}}(%rip)
28; CHECK-NEXT:    leaq {{[0-9]+}}(%rsp), %rcx
29; CHECK-NEXT:    # kill: def $ecx killed $ecx killed $rcx
30; CHECK-NEXT:    callq fn2
31; CHECK-NEXT:    addq $4136, %rsp # imm = 0x1028
32; CHECK-NEXT:    retq
33entry:
34  %ctx = alloca %struct.A, align 1
35  %0 = load i32, i32* @a, align 4
36  %tobool = icmp eq i32 %0, 0
37  %div = sdiv i32 %0, 6
38  %cond = select i1 %tobool, i32 %div, i32 %0
39  store i32 %cond, i32* @b, align 4
40  %1 = getelementptr inbounds %struct.A, %struct.A* %ctx, i64 0, i32 0, i64 0
41  call void @llvm.lifetime.start.p0i8(i64 4096, i8* nonnull %1)
42  %2 = ptrtoint %struct.A* %ctx to i64
43  %3 = trunc i64 %2 to i32
44  call void @fn2(i32 %3)
45  call void @llvm.lifetime.end.p0i8(i64 4096, i8* nonnull %1)
46  ret void
47}
48
49declare void @fn2(i32)
50declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
51declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
52
53