1 ; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
2 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4 declare { i16, i1 } @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
5 declare { i16, i1 } @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone
6 declare { i16, i1 } @llvm.ssub.with.overflow.i16(i16, i16) nounwind readnone
7 declare { i16, i1 } @llvm.usub.with.overflow.i16(i16, i16) nounwind readnone
8 declare { i16, i1 } @llvm.smul.with.overflow.i16(i16, i16) nounwind readnone
9 declare { i16, i1 } @llvm.umul.with.overflow.i16(i16, i16) nounwind readnone
11 ; CHECK-LABEL: Classifying expressions for: @uadd_exhaustive
12 ; CHECK: Loop %for.body: backedge-taken count is 35
13 define void @uadd_exhaustive() {
15 br i1 undef, label %for.end, label %for.body.preheader
17 for.body.preheader: ; preds = %entry
20 for.body: ; preds = %for.body.preheader, %for.body
21 %indvars.iv = phi i16 [ %math, %for.body ], [ 65500, %for.body.preheader ]
22 %0 = call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %indvars.iv, i16 1)
23 %math = extractvalue { i16, i1 } %0, 0
24 %ov = extractvalue { i16, i1 } %0, 1
25 br i1 %ov, label %for.end, label %for.body
27 for.end: ; preds = %for.body, %entry
31 ; CHECK-LABEL: Classifying expressions for: @sadd_exhaustive
32 ; CHECK: Loop %for.body: backedge-taken count is 67
33 define void @sadd_exhaustive() {
35 br i1 undef, label %for.end, label %for.body.preheader
37 for.body.preheader: ; preds = %entry
40 for.body: ; preds = %for.body.preheader, %for.body
41 %indvars.iv = phi i16 [ %math, %for.body ], [ 32700, %for.body.preheader ]
42 %0 = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 %indvars.iv, i16 1)
43 %math = extractvalue { i16, i1 } %0, 0
44 %ov = extractvalue { i16, i1 } %0, 1
45 br i1 %ov, label %for.end, label %for.body
47 for.end: ; preds = %for.body, %entry
51 ; CHECK-LABEL: Classifying expressions for: @usub_exhaustive
52 ; CHECK: Loop %for.body: backedge-taken count is 50
53 define void @usub_exhaustive() {
55 br i1 undef, label %for.end, label %for.body.preheader
57 for.body.preheader: ; preds = %entry
60 for.body: ; preds = %for.body.preheader, %for.body
61 %indvars.iv = phi i16 [ %math, %for.body ], [ 50, %for.body.preheader ]
62 %0 = call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %indvars.iv, i16 1)
63 %math = extractvalue { i16, i1 } %0, 0
64 %ov = extractvalue { i16, i1 } %0, 1
65 br i1 %ov, label %for.end, label %for.body
67 for.end: ; preds = %for.body, %entry
71 ; CHECK-LABEL: Classifying expressions for: @ssub_exhaustive
72 ; CHECK: Loop %for.body: backedge-taken count is 68
73 define void @ssub_exhaustive() {
75 br i1 undef, label %for.end, label %for.body.preheader
77 for.body.preheader: ; preds = %entry
80 for.body: ; preds = %for.body.preheader, %for.body
81 %indvars.iv = phi i16 [ %math, %for.body ], [ -32700, %for.body.preheader ]
82 %0 = call { i16, i1 } @llvm.ssub.with.overflow.i16(i16 %indvars.iv, i16 1)
83 %math = extractvalue { i16, i1 } %0, 0
84 %ov = extractvalue { i16, i1 } %0, 1
85 br i1 %ov, label %for.end, label %for.body
87 for.end: ; preds = %for.body, %entry
91 ; CHECK-LABEL: Classifying expressions for: @smul_exhaustive
92 ; CHECK: Loop %for.body: backedge-taken count is 14
93 define void @smul_exhaustive() {
95 br i1 undef, label %for.end, label %for.body.preheader
97 for.body.preheader: ; preds = %entry
100 for.body: ; preds = %for.body.preheader, %for.body
101 %indvars.iv = phi i16 [ %math, %for.body ], [ 1, %for.body.preheader ]
102 %0 = call { i16, i1 } @llvm.smul.with.overflow.i16(i16 %indvars.iv, i16 2)
103 %math = extractvalue { i16, i1 } %0, 0
104 %ov = extractvalue { i16, i1 } %0, 1
105 br i1 %ov, label %for.end, label %for.body
107 for.end: ; preds = %for.body, %entry
111 ; CHECK-LABEL: Classifying expressions for: @umul_exhaustive
112 ; CHECK: Loop %for.body: backedge-taken count is 15
113 define void @umul_exhaustive() {
115 br i1 undef, label %for.end, label %for.body.preheader
117 for.body.preheader: ; preds = %entry
120 for.body: ; preds = %for.body.preheader, %for.body
121 %indvars.iv = phi i16 [ %math, %for.body ], [ 1, %for.body.preheader ]
122 %0 = call { i16, i1 } @llvm.umul.with.overflow.i16(i16 %indvars.iv, i16 2)
123 %math = extractvalue { i16, i1 } %0, 0
124 %ov = extractvalue { i16, i1 } %0, 1
125 br i1 %ov, label %for.end, label %for.body
127 for.end: ; preds = %for.body, %entry