1 ; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
3 declare { i16, i1 } @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
4 declare { i16, i1 } @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone
5 declare { i16, i1 } @llvm.ssub.with.overflow.i16(i16, i16) nounwind readnone
6 declare { i16, i1 } @llvm.usub.with.overflow.i16(i16, i16) nounwind readnone
7 declare { i16, i1 } @llvm.smul.with.overflow.i16(i16, i16) nounwind readnone
8 declare { i16, i1 } @llvm.umul.with.overflow.i16(i16, i16) nounwind readnone
10 ; CHECK-LABEL: Classifying expressions for: @uadd_exhaustive
11 ; CHECK: Loop %for.body: backedge-taken count is 35
12 define void @uadd_exhaustive() {
14 br i1 undef, label %for.end, label %for.body.preheader
16 for.body.preheader: ; preds = %entry
19 for.body: ; preds = %for.body.preheader, %for.body
20 %indvars.iv = phi i16 [ %math, %for.body ], [ 65500, %for.body.preheader ]
21 %0 = call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %indvars.iv, i16 1)
22 %math = extractvalue { i16, i1 } %0, 0
23 %ov = extractvalue { i16, i1 } %0, 1
24 br i1 %ov, label %for.end, label %for.body
26 for.end: ; preds = %for.body, %entry
30 ; CHECK-LABEL: Classifying expressions for: @sadd_exhaustive
31 ; CHECK: Loop %for.body: backedge-taken count is 67
32 define void @sadd_exhaustive() {
34 br i1 undef, label %for.end, label %for.body.preheader
36 for.body.preheader: ; preds = %entry
39 for.body: ; preds = %for.body.preheader, %for.body
40 %indvars.iv = phi i16 [ %math, %for.body ], [ 32700, %for.body.preheader ]
41 %0 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 %indvars.iv, i16 1)
42 %math = extractvalue { i16, i1 } %0, 0
43 %ov = extractvalue { i16, i1 } %0, 1
44 br i1 %ov, label %for.end, label %for.body
46 for.end: ; preds = %for.body, %entry
50 ; CHECK-LABEL: Classifying expressions for: @usub_exhaustive
51 ; CHECK: Loop %for.body: backedge-taken count is 50
52 define void @usub_exhaustive() {
54 br i1 undef, label %for.end, label %for.body.preheader
56 for.body.preheader: ; preds = %entry
59 for.body: ; preds = %for.body.preheader, %for.body
60 %indvars.iv = phi i16 [ %math, %for.body ], [ 50, %for.body.preheader ]
61 %0 = call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %indvars.iv, i16 1)
62 %math = extractvalue { i16, i1 } %0, 0
63 %ov = extractvalue { i16, i1 } %0, 1
64 br i1 %ov, label %for.end, label %for.body
66 for.end: ; preds = %for.body, %entry
70 ; CHECK-LABEL: Classifying expressions for: @ssub_exhaustive
71 ; CHECK: Loop %for.body: backedge-taken count is 68
72 define void @ssub_exhaustive() {
74 br i1 undef, label %for.end, label %for.body.preheader
76 for.body.preheader: ; preds = %entry
79 for.body: ; preds = %for.body.preheader, %for.body
80 %indvars.iv = phi i16 [ %math, %for.body ], [ -32700, %for.body.preheader ]
81 %0 = call { i16, i1 } @llvm.ssub.with.overflow.i16(i16 %indvars.iv, i16 1)
82 %math = extractvalue { i16, i1 } %0, 0
83 %ov = extractvalue { i16, i1 } %0, 1
84 br i1 %ov, label %for.end, label %for.body
86 for.end: ; preds = %for.body, %entry
90 ; CHECK-LABEL: Classifying expressions for: @smul_exhaustive
91 ; CHECK: Loop %for.body: backedge-taken count is 14
92 define void @smul_exhaustive() {
94 br i1 undef, label %for.end, label %for.body.preheader
96 for.body.preheader: ; preds = %entry
99 for.body: ; preds = %for.body.preheader, %for.body
100 %indvars.iv = phi i16 [ %math, %for.body ], [ 1, %for.body.preheader ]
101 %0 = call { i16, i1 } @llvm.smul.with.overflow.i16(i16 %indvars.iv, i16 2)
102 %math = extractvalue { i16, i1 } %0, 0
103 %ov = extractvalue { i16, i1 } %0, 1
104 br i1 %ov, label %for.end, label %for.body
106 for.end: ; preds = %for.body, %entry
110 ; CHECK-LABEL: Classifying expressions for: @umul_exhaustive
111 ; CHECK: Loop %for.body: backedge-taken count is 15
112 define void @umul_exhaustive() {
114 br i1 undef, label %for.end, label %for.body.preheader
116 for.body.preheader: ; preds = %entry
119 for.body: ; preds = %for.body.preheader, %for.body
120 %indvars.iv = phi i16 [ %math, %for.body ], [ 1, %for.body.preheader ]
121 %0 = call { i16, i1 } @llvm.umul.with.overflow.i16(i16 %indvars.iv, i16 2)
122 %math = extractvalue { i16, i1 } %0, 0
123 %ov = extractvalue { i16, i1 } %0, 1
124 br i1 %ov, label %for.end, label %for.body
126 for.end: ; preds = %for.body, %entry