1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -S | FileCheck %s
4 ; Indvars should be able to compute the exit value of this loop
5 ; without any additional arithmetic. The only add needed should
6 ; be the canonical IV increment.
8 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"
10 define void @foo(double* %p, i32 %n) nounwind {
13 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sgt i32 [[N:%.*]], 0
14 ; CHECK-NEXT: br i1 [[TMP0]], label [[BB_NPH:%.*]], label [[RETURN:%.*]]
16 ; CHECK-NEXT: br label [[BB2:%.*]]
18 ; CHECK-NEXT: [[I_01:%.*]] = phi i32 [ [[TMP7:%.*]], [[BB3:%.*]] ], [ 0, [[BB_NPH]] ]
19 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[I_01]] to i64
20 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr double, double* [[P:%.*]], i64 [[TMP1]]
21 ; CHECK-NEXT: [[TMP3:%.*]] = load double, double* [[TMP2]], align 8
22 ; CHECK-NEXT: [[TMP4:%.*]] = fmul double [[TMP3]], 1.100000e+00
23 ; CHECK-NEXT: [[TMP5:%.*]] = sext i32 [[I_01]] to i64
24 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr double, double* [[P]], i64 [[TMP5]]
25 ; CHECK-NEXT: store double [[TMP4]], double* [[TMP6]], align 8
26 ; CHECK-NEXT: [[TMP7]] = add nuw nsw i32 [[I_01]], 1
27 ; CHECK-NEXT: br label [[BB3]]
29 ; CHECK-NEXT: [[TMP8:%.*]] = icmp slt i32 [[TMP7]], [[N]]
30 ; CHECK-NEXT: br i1 [[TMP8]], label [[BB2]], label [[BB3_RETURN_CRIT_EDGE:%.*]]
31 ; CHECK: bb3.return_crit_edge:
32 ; CHECK-NEXT: br label [[RETURN]]
34 ; CHECK-NEXT: ret void
38 %0 = icmp sgt i32 %n, 0
39 br i1 %0, label %bb.nph, label %return
41 bb.nph: ; preds = %entry
44 bb2: ; preds = %bb3, %bb.nph
45 %i.01 = phi i32 [ %7, %bb3 ], [ 0, %bb.nph ]
46 %1 = sext i32 %i.01 to i64
47 %2 = getelementptr double, double* %p, i64 %1
48 %3 = load double, double* %2, align 8
49 %4 = fmul double %3, 1.100000e+00
50 %5 = sext i32 %i.01 to i64
51 %6 = getelementptr double, double* %p, i64 %5
52 store double %4, double* %6, align 8
57 %8 = icmp slt i32 %7, %n
58 br i1 %8, label %bb2, label %bb3.return_crit_edge
60 bb3.return_crit_edge: ; preds = %bb3
63 return: ; preds = %bb3.return_crit_edge, %entry