1 ; RUN: opt < %s -scalar-evolution -analyze \
4 ; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64)
5 ; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64)
6 ; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64)
7 ; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64)
8 ; CHECK: --> (sext i{{.}} {{{.*}},+,{{.*}}}<%bb1> to i64)
11 ; Don't convert (sext {...,+,...}) to {sext(...),+,sext(...)} in cases
12 ; where the trip count is not within range.
14 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
15 target triple = "x86_64-unknown-linux-gnu"
17 define void @foo0(double* nocapture %x) nounwind {
21 bb1: ; preds = %bb1, %bb1.thread
22 %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
23 %0 = trunc i64 %i.0.reg2mem.0 to i7 ; <i8> [#uses=1]
24 %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
25 %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
26 %3 = getelementptr double, double* %x, i64 %2 ; <double*> [#uses=1]
27 %4 = load double, double* %3, align 8 ; <double> [#uses=1]
28 %5 = fmul double %4, 3.900000e+00 ; <double> [#uses=1]
29 %6 = sext i7 %0 to i64 ; <i64> [#uses=1]
30 %7 = getelementptr double, double* %x, i64 %6 ; <double*> [#uses=1]
31 store double %5, double* %7, align 8
32 %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
33 %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
34 br i1 %9, label %return, label %bb1
36 return: ; preds = %bb1
40 define void @foo1(double* nocapture %x) nounwind {
44 bb1: ; preds = %bb1, %bb1.thread
45 %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
46 %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
47 %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
48 %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
49 %3 = getelementptr double, double* %x, i64 %2 ; <double*> [#uses=1]
50 %4 = load double, double* %3, align 8 ; <double> [#uses=1]
51 %5 = fmul double %4, 3.900000e+00 ; <double> [#uses=1]
52 %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
53 %7 = getelementptr double, double* %x, i64 %6 ; <double*> [#uses=1]
54 store double %5, double* %7, align 8
55 %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
56 %9 = icmp sgt i64 %8, 128 ; <i1> [#uses=1]
57 br i1 %9, label %return, label %bb1
59 return: ; preds = %bb1
63 define void @foo2(double* nocapture %x) nounwind {
67 bb1: ; preds = %bb1, %bb1.thread
68 %i.0.reg2mem.0 = phi i64 [ -129, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
69 %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
70 %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
71 %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
72 %3 = getelementptr double, double* %x, i64 %2 ; <double*> [#uses=1]
73 %4 = load double, double* %3, align 8 ; <double> [#uses=1]
74 %5 = fmul double %4, 3.900000e+00 ; <double> [#uses=1]
75 %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
76 %7 = getelementptr double, double* %x, i64 %6 ; <double*> [#uses=1]
77 store double %5, double* %7, align 8
78 %8 = add i64 %i.0.reg2mem.0, 1 ; <i64> [#uses=2]
79 %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
80 br i1 %9, label %return, label %bb1
82 return: ; preds = %bb1
86 define void @foo3(double* nocapture %x) nounwind {
90 bb1: ; preds = %bb1, %bb1.thread
91 %i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
92 %0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
93 %1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
94 %2 = sext i9 %1 to i64 ; <i64> [#uses=1]
95 %3 = getelementptr double, double* %x, i64 %2 ; <double*> [#uses=1]
96 %4 = load double, double* %3, align 8 ; <double> [#uses=1]
97 %5 = fmul double %4, 3.900000e+00 ; <double> [#uses=1]
98 %6 = sext i8 %0 to i64 ; <i64> [#uses=1]
99 %7 = getelementptr double, double* %x, i64 %6 ; <double*> [#uses=1]
100 store double %5, double* %7, align 8
101 %8 = add i64 %i.0.reg2mem.0, -1 ; <i64> [#uses=2]
102 %9 = icmp sgt i64 %8, 127 ; <i1> [#uses=1]
103 br i1 %9, label %return, label %bb1
105 return: ; preds = %bb1