1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=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, ptr %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]], ptr [[P:%.*]], align 4
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, ptr %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: [[UGLYGEP:%.*]] = getelementptr i8, ptr @data, i64 [[TMP3]]
49 ; CHECK-NEXT: br label [[LOOP:%.*]]
51 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ @data, [[ENTRY:%.*]] ], [ [[P_INC:%.*]], [[LOOP]] ]
52 ; CHECK-NEXT: [[P_INC]] = getelementptr inbounds i8, ptr [[P]], i64 1
53 ; CHECK-NEXT: store volatile i8 0, ptr [[P_INC]], align 1
54 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq ptr [[P_INC]], [[UGLYGEP]]
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 ptr [ @data, %entry ], [ %p.inc, %loop ]
65 %i.inc = add nuw i32 %i, 1
66 %p.inc = getelementptr inbounds i8, ptr %p, i64 1
67 store volatile i8 0, ptr %p.inc
68 %and = and i32 %i.inc, 7
69 %cmp = icmp eq i32 %and, 0
70 br i1 %cmp, label %end, label %loop