llvm.org GIT mirror llvm / 7615895
[LFTR] Add tests for PR41998; NFC The limit for the pointer case is incorrect. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364128 91177308-0d34-0410-b5e6-96231b3b80d8 Nikita Popov 2 months ago
1 changed file(s) with 73 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -indvars -S | FileCheck %s
2
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4
5 define void @test_int(i32 %start, i32* %p) {
6 ; CHECK-LABEL: @test_int(
7 ; CHECK-NEXT: entry:
8 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[START:%.*]] to i3
9 ; CHECK-NEXT: [[TMP1:%.*]] = sub i3 0, [[TMP0]]
10 ; CHECK-NEXT: br label [[LOOP:%.*]]
11 ; CHECK: loop:
12 ; CHECK-NEXT: [[I2:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I2_INC:%.*]], [[LOOP]] ]
13 ; CHECK-NEXT: [[I2_INC]] = add nuw nsw i32 [[I2]], 1
14 ; CHECK-NEXT: store volatile i32 [[I2_INC]], i32* [[P:%.*]]
15 ; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i32 [[I2_INC]] to i3
16 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i3 [[LFTR_WIDEIV]], [[TMP1]]
17 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END:%.*]], label [[LOOP]]
18 ; CHECK: end:
19 ; CHECK-NEXT: ret void
20 ;
21 entry:
22 br label %loop
23
24 loop:
25 %i = phi i32 [ %start, %entry ], [ %i.inc, %loop ]
26 %i2 = phi i32 [ 0, %entry ], [ %i2.inc, %loop ]
27 %i.inc = add nuw i32 %i, 1
28 %i2.inc = add nuw i32 %i2, 1
29 store volatile i32 %i2.inc, i32* %p
30 %and = and i32 %i.inc, 7
31 %cmp = icmp eq i32 %and, 0
32 br i1 %cmp, label %end, label %loop
33
34 end:
35 ret void
36 }
37
38 @data = global [256 x i8] zeroinitializer
39
40 define void @test_ptr(i32 %start) {
41 ; CHECK-LABEL: @test_ptr(
42 ; CHECK-NEXT: entry:
43 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[START:%.*]] to i3
44 ; CHECK-NEXT: [[TMP1:%.*]] = sub i3 0, [[TMP0]]
45 ; CHECK-NEXT: [[TMP2:%.*]] = zext i3 [[TMP1]] to i64
46 ; CHECK-NEXT: [[LFTR_LIMIT:%.*]] = getelementptr i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), i64 [[TMP2]]
47 ; CHECK-NEXT: br label [[LOOP:%.*]]
48 ; CHECK: loop:
49 ; CHECK-NEXT: [[P:%.*]] = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), [[ENTRY:%.*]] ], [ [[P_INC:%.*]], [[LOOP]] ]
50 ; CHECK-NEXT: [[P_INC]] = getelementptr inbounds i8, i8* [[P]], i64 1
51 ; CHECK-NEXT: store volatile i8 0, i8* [[P_INC]]
52 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i8* [[P_INC]], [[LFTR_LIMIT]]
53 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END:%.*]], label [[LOOP]]
54 ; CHECK: end:
55 ; CHECK-NEXT: ret void
56 ;
57 entry:
58 br label %loop
59
60 loop:
61 %i = phi i32 [ %start, %entry ], [ %i.inc, %loop ]
62 %p = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), %entry ], [ %p.inc, %loop ]
63 %i.inc = add nuw i32 %i, 1
64 %p.inc = getelementptr inbounds i8, i8* %p, i64 1
65 store volatile i8 0, i8* %p.inc
66 %and = and i32 %i.inc, 7
67 %cmp = icmp eq i32 %and, 0
68 br i1 %cmp, label %end, label %loop
69
70 end:
71 ret void
72 }