1 ; RUN: llc < %s -march=x86 -regalloc=greedy -stop-after=greedy | FileCheck %s
2 ; Make sure bad eviction sequence doesnt occur
4 ; Part of the fix for bugzilla 26810.
5 ; This test is meant to make sure bad eviction sequence like the one described
8 ; movl %ebp, 8($esp) # 4-byte Spill
19 ; movl 16($esp), %ebp # 4 - byte Reload
21 ; Make sure we have no redundant copies in the problematic code seqtion
22 ; CHECK-LABEL: name: bar
23 ; CHECK: bb.3.for.body:
30 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
31 target triple = "i386-pc-linux-gnu"
34 ; Function Attrs: norecurse nounwind readonly
35 define i32 @bar(i32 %size, i32* nocapture readonly %arr, i32* nocapture readnone %tmp) local_unnamed_addr #1 {
37 %0 = load i32, i32* %arr, align 4, !tbaa !3
38 %arrayidx3 = getelementptr inbounds i32, i32* %arr, i32 1
39 %1 = load i32, i32* %arrayidx3, align 4, !tbaa !3
40 %arrayidx5 = getelementptr inbounds i32, i32* %arr, i32 2
41 %2 = load i32, i32* %arrayidx5, align 4, !tbaa !3
42 %arrayidx7 = getelementptr inbounds i32, i32* %arr, i32 3
43 %3 = load i32, i32* %arrayidx7, align 4, !tbaa !3
44 %arrayidx9 = getelementptr inbounds i32, i32* %arr, i32 4
45 %4 = load i32, i32* %arrayidx9, align 4, !tbaa !3
46 %arrayidx11 = getelementptr inbounds i32, i32* %arr, i32 5
47 %5 = load i32, i32* %arrayidx11, align 4, !tbaa !3
48 %arrayidx13 = getelementptr inbounds i32, i32* %arr, i32 6
49 %6 = load i32, i32* %arrayidx13, align 4, !tbaa !3
50 %arrayidx15 = getelementptr inbounds i32, i32* %arr, i32 7
51 %7 = load i32, i32* %arrayidx15, align 4, !tbaa !3
52 %arrayidx17 = getelementptr inbounds i32, i32* %arr, i32 8
53 %8 = load i32, i32* %arrayidx17, align 4, !tbaa !3
54 %cmp69 = icmp sgt i32 %size, 1
55 br i1 %cmp69, label %for.body, label %for.cond.cleanup
57 for.cond.cleanup: ; preds = %for.body, %entry
58 %x0.0.lcssa = phi i32 [ %0, %entry ], [ %add, %for.body ]
59 %x1.0.lcssa = phi i32 [ %1, %entry ], [ %sub, %for.body ]
60 %x2.0.lcssa = phi i32 [ %2, %entry ], [ %mul, %for.body ]
61 %x3.0.lcssa = phi i32 [ %3, %entry ], [ %div, %for.body ]
62 %x4.0.lcssa = phi i32 [ %4, %entry ], [ %add19, %for.body ]
63 %x5.0.lcssa = phi i32 [ %5, %entry ], [ %sub20, %for.body ]
64 %x6.0.lcssa = phi i32 [ %6, %entry ], [ %add21, %for.body ]
65 %x7.0.lcssa = phi i32 [ %7, %entry ], [ %mul22, %for.body ]
66 %x8.0.lcssa = phi i32 [ %8, %entry ], [ %sub23, %for.body ]
67 %mul24 = mul nsw i32 %x1.0.lcssa, %x0.0.lcssa
68 %mul25 = mul nsw i32 %mul24, %x2.0.lcssa
69 %mul26 = mul nsw i32 %mul25, %x3.0.lcssa
70 %mul27 = mul nsw i32 %mul26, %x4.0.lcssa
71 %mul28 = mul nsw i32 %mul27, %x5.0.lcssa
72 %mul29 = mul nsw i32 %mul28, %x6.0.lcssa
73 %mul30 = mul nsw i32 %mul29, %x7.0.lcssa
74 %mul31 = mul nsw i32 %mul30, %x8.0.lcssa
77 for.body: ; preds = %entry, %for.body
78 %i.079 = phi i32 [ %inc, %for.body ], [ 1, %entry ]
79 %x8.078 = phi i32 [ %sub23, %for.body ], [ %8, %entry ]
80 %x7.077 = phi i32 [ %mul22, %for.body ], [ %7, %entry ]
81 %x6.076 = phi i32 [ %add21, %for.body ], [ %6, %entry ]
82 %x5.075 = phi i32 [ %sub20, %for.body ], [ %5, %entry ]
83 %x4.074 = phi i32 [ %add19, %for.body ], [ %4, %entry ]
84 %x3.073 = phi i32 [ %div, %for.body ], [ %3, %entry ]
85 %x2.072 = phi i32 [ %mul, %for.body ], [ %2, %entry ]
86 %x1.071 = phi i32 [ %sub, %for.body ], [ %1, %entry ]
87 %x0.070 = phi i32 [ %add, %for.body ], [ %0, %entry ]
88 %add = add nsw i32 %x1.071, %x0.070
89 %sub = sub nsw i32 %x1.071, %x2.072
90 %mul = mul nsw i32 %x3.073, %x2.072
91 %div = sdiv i32 %x3.073, %x4.074
92 %add19 = add nsw i32 %x5.075, %x4.074
93 %sub20 = sub nsw i32 %x5.075, %x6.076
94 %add21 = add nsw i32 %x7.077, %x6.076
95 %mul22 = mul nsw i32 %x8.078, %x7.077
96 %sub23 = sub nsw i32 %x8.078, %add
97 %inc = add nuw nsw i32 %i.079, 1
98 %exitcond = icmp eq i32 %inc, %size
99 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !llvm.loop !7
102 attributes #0 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
103 attributes #1 = { norecurse nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
105 !llvm.module.flags = !{!0, !1}
108 !0 = !{i32 1, !"NumRegisterParameters", i32 0}
109 !1 = !{i32 1, !"wchar_size", i32 2}
110 !2 = !{!"clang version 5.0.0 (cfe/trunk 305640)"}
111 !3 = !{!4, !4, i64 0}
112 !4 = !{!"int", !5, i64 0}
113 !5 = !{!"omnipotent char", !6, i64 0}
114 !6 = !{!"Simple C/C++ TBAA"}
115 !7 = distinct !{!7, !8}
116 !8 = !{!"llvm.loop.unroll.disable"}