1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -indvars -S | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 define void @test_int(i32 %start, i32* %p) {
7 ; CHECK-LABEL: @test_int(
9 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[START:%.*]] to i3
10 ; CHECK-NEXT: [[TMP1:%.*]] = sub i3 0, [[TMP0]]
11 ; CHECK-NEXT: br label [[LOOP:%.*]]
13 ; CHECK-NEXT: [[I2:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I2_INC:%.*]], [[LOOP]] ]
14 ; CHECK-NEXT: [[I2_INC]] = add nuw nsw i32 [[I2]], 1
15 ; CHECK-NEXT: store volatile i32 [[I2_INC]], i32* [[P:%.*]]
16 ; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i32 [[I2_INC]] to i3
17 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i3 [[LFTR_WIDEIV]], [[TMP1]]
18 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END:%.*]], label [[LOOP]]
20 ; CHECK-NEXT: ret void
26 %i = phi i32 [ %start, %entry ], [ %i.inc, %loop ]
27 %i2 = phi i32 [ 0, %entry ], [ %i2.inc, %loop ]
28 %i.inc = add nuw i32 %i, 1
29 %i2.inc = add nuw i32 %i2, 1
30 store volatile i32 %i2.inc, i32* %p
31 %and = and i32 %i.inc, 7
32 %cmp = icmp eq i32 %and, 0
33 br i1 %cmp, label %end, label %loop
39 @data = global [256 x i8] zeroinitializer
41 define void @test_ptr(i32 %start) {
42 ; CHECK-LABEL: @test_ptr(
44 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[START:%.*]] to i3
45 ; CHECK-NEXT: [[TMP1:%.*]] = sub i3 -1, [[TMP0]]
46 ; CHECK-NEXT: [[TMP2:%.*]] = zext i3 [[TMP1]] to i64
47 ; CHECK-NEXT: [[TMP3:%.*]] = add nuw nsw i64 [[TMP2]], 1
48 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr [256 x i8], [256 x i8]* @data, i64 0, i64 [[TMP3]]
49 ; CHECK-NEXT: br label [[LOOP:%.*]]
51 ; CHECK-NEXT: [[P:%.*]] = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), [[ENTRY:%.*]] ], [ [[P_INC:%.*]], [[LOOP]] ]
52 ; CHECK-NEXT: [[P_INC]] = getelementptr inbounds i8, i8* [[P]], i64 1
53 ; CHECK-NEXT: store volatile i8 0, i8* [[P_INC]]
54 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i8* [[P_INC]], [[SCEVGEP]]
55 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END:%.*]], label [[LOOP]]
57 ; CHECK-NEXT: ret void
63 %i = phi i32 [ %start, %entry ], [ %i.inc, %loop ]
64 %p = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), %entry ], [ %p.inc, %loop ]
65 %i.inc = add nuw i32 %i, 1
66 %p.inc = getelementptr inbounds i8, i8* %p, i64 1
67 store volatile i8 0, i8* %p.inc
68 %and = and i32 %i.inc, 7
69 %cmp = icmp eq i32 %and, 0
70 br i1 %cmp, label %end, label %loop