1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc %s -o - -enable-shrink-wrap=true -no-x86-call-frame-opt | FileCheck %s --check-prefix=ENABLE
3 ; RUN: llc %s -o - -enable-shrink-wrap=false -no-x86-call-frame-opt | FileCheck %s --check-prefix=DISABLE
4 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
5 target triple = "i386-apple-macosx10.5"
7 @a = common global i32 0, align 4
8 @d = internal unnamed_addr global i1 false
9 @b = common global i32 0, align 4
10 @e = common global i8 0, align 1
11 @f = common global i8 0, align 1
12 @c = common global i32 0, align 4
13 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
16 ; Check that we are clobbering the flags when they are live-in of the
17 ; prologue block and the prologue needs to adjust the stack.
20 define i32 @eflagsLiveInPrologue() #0 {
21 ; ENABLE-LABEL: eflagsLiveInPrologue:
22 ; ENABLE: ## %bb.0: ## %entry
23 ; ENABLE-NEXT: pushl %esi
24 ; ENABLE-NEXT: subl $8, %esp
25 ; ENABLE-NEXT: movl L_a$non_lazy_ptr, %eax
26 ; ENABLE-NEXT: cmpl $0, (%eax)
27 ; ENABLE-NEXT: je LBB0_2
28 ; ENABLE-NEXT: ## %bb.1: ## %if.then
29 ; ENABLE-NEXT: movb $1, _d
30 ; ENABLE-NEXT: LBB0_2: ## %for.cond.preheader
31 ; ENABLE-NEXT: movl L_b$non_lazy_ptr, %eax
32 ; ENABLE-NEXT: movl (%eax), %eax
33 ; ENABLE-NEXT: testl %eax, %eax
34 ; ENABLE-NEXT: je LBB0_4
35 ; ENABLE-NEXT: .p2align 4, 0x90
36 ; ENABLE-NEXT: LBB0_3: ## %for.body
37 ; ENABLE-NEXT: ## =>This Inner Loop Header: Depth=1
38 ; ENABLE-NEXT: jmp LBB0_3
39 ; ENABLE-NEXT: LBB0_4: ## %for.end
40 ; ENABLE-NEXT: xorl %edx, %edx
41 ; ENABLE-NEXT: cmpb $0, _d
42 ; ENABLE-NEXT: movl $6, %ecx
43 ; ENABLE-NEXT: cmovnel %edx, %ecx
44 ; ENABLE-NEXT: movl L_e$non_lazy_ptr, %edx
45 ; ENABLE-NEXT: movb %cl, (%edx)
46 ; ENABLE-NEXT: leal 1(%ecx), %esi
48 ; ENABLE-NEXT: idivl %esi
49 ; ENABLE-NEXT: movl L_c$non_lazy_ptr, %eax
50 ; ENABLE-NEXT: movl %edx, (%eax)
51 ; ENABLE-NEXT: movl %ecx, {{[0-9]+}}(%esp)
52 ; ENABLE-NEXT: movl $L_.str, (%esp)
53 ; ENABLE-NEXT: calll _varfunc
54 ; ENABLE-NEXT: xorl %eax, %eax
55 ; ENABLE-NEXT: addl $8, %esp
56 ; ENABLE-NEXT: popl %esi
59 ; DISABLE-LABEL: eflagsLiveInPrologue:
60 ; DISABLE: ## %bb.0: ## %entry
61 ; DISABLE-NEXT: pushl %esi
62 ; DISABLE-NEXT: subl $8, %esp
63 ; DISABLE-NEXT: movl L_a$non_lazy_ptr, %eax
64 ; DISABLE-NEXT: cmpl $0, (%eax)
65 ; DISABLE-NEXT: je LBB0_2
66 ; DISABLE-NEXT: ## %bb.1: ## %if.then
67 ; DISABLE-NEXT: movb $1, _d
68 ; DISABLE-NEXT: LBB0_2: ## %for.cond.preheader
69 ; DISABLE-NEXT: movl L_b$non_lazy_ptr, %eax
70 ; DISABLE-NEXT: movl (%eax), %eax
71 ; DISABLE-NEXT: testl %eax, %eax
72 ; DISABLE-NEXT: je LBB0_4
73 ; DISABLE-NEXT: .p2align 4, 0x90
74 ; DISABLE-NEXT: LBB0_3: ## %for.body
75 ; DISABLE-NEXT: ## =>This Inner Loop Header: Depth=1
76 ; DISABLE-NEXT: jmp LBB0_3
77 ; DISABLE-NEXT: LBB0_4: ## %for.end
78 ; DISABLE-NEXT: xorl %edx, %edx
79 ; DISABLE-NEXT: cmpb $0, _d
80 ; DISABLE-NEXT: movl $6, %ecx
81 ; DISABLE-NEXT: cmovnel %edx, %ecx
82 ; DISABLE-NEXT: movl L_e$non_lazy_ptr, %edx
83 ; DISABLE-NEXT: movb %cl, (%edx)
84 ; DISABLE-NEXT: leal 1(%ecx), %esi
86 ; DISABLE-NEXT: idivl %esi
87 ; DISABLE-NEXT: movl L_c$non_lazy_ptr, %eax
88 ; DISABLE-NEXT: movl %edx, (%eax)
89 ; DISABLE-NEXT: movl %ecx, {{[0-9]+}}(%esp)
90 ; DISABLE-NEXT: movl $L_.str, (%esp)
91 ; DISABLE-NEXT: calll _varfunc
92 ; DISABLE-NEXT: xorl %eax, %eax
93 ; DISABLE-NEXT: addl $8, %esp
94 ; DISABLE-NEXT: popl %esi
97 %tmp = load i32, i32* @a, align 4
98 %tobool = icmp eq i32 %tmp, 0
99 br i1 %tobool, label %for.cond.preheader, label %if.then
101 if.then: ; preds = %entry
102 store i1 true, i1* @d, align 1
103 br label %for.cond.preheader
105 for.cond.preheader: ; preds = %if.then, %entry
106 %tmp1 = load i32, i32* @b, align 4
107 %tobool14 = icmp eq i32 %tmp1, 0
108 br i1 %tobool14, label %for.end, label %for.body.preheader
110 for.body.preheader: ; preds = %for.cond.preheader
113 for.body: ; preds = %for.body, %for.body.preheader
116 for.end: ; preds = %for.cond.preheader
117 %.b3 = load i1, i1* @d, align 1
118 %tmp2 = select i1 %.b3, i8 0, i8 6
119 store i8 %tmp2, i8* @e, align 1
120 %tmp3 = load i8, i8* @e, align 1
121 %conv = sext i8 %tmp3 to i32
122 %add = add nsw i32 %conv, 1
123 %rem = srem i32 %tmp1, %add
124 store i32 %rem, i32* @c, align 4
125 %conv2 = select i1 %.b3, i32 0, i32 6
126 %call = tail call i32 (i8*, ...) @varfunc(i8* nonnull getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %conv2) #1
130 ; Function Attrs: nounwind
131 declare i32 @varfunc(i8* nocapture readonly, ...) #0
133 attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse" "unsafe-fp-math"="false" "use-soft-float"="false" }
134 attributes #1 = { nounwind }