~pali/+junk/llvm-toolchain-3.7

« back to all changes in this revision

Viewing changes to test/CodeGen/Hexagon/hwloop-cleanup.ll

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2015-07-15 17:51:08 UTC
  • Revision ID: package-import@ubuntu.com-20150715175108-l8mynwovkx4zx697
Tags: upstream-3.7~+rc2
ImportĀ upstreamĀ versionĀ 3.7~+rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; RUN: llc -march=hexagon -mcpu=hexagonv4 -no-phi-elim-live-out-early-exit \
 
2
; RUN:    < %s | FileCheck %s
 
3
; Check that we remove the compare and induction variable instructions
 
4
; after generating hardware loops.
 
5
; Bug 6685.
 
6
 
 
7
; CHECK: loop0
 
8
; CHECK-NOT: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#-1)
 
9
; CHECK-NOT: cmp.eq
 
10
; CHECK: endloop0
 
11
 
 
12
define i32 @test1(i32* nocapture %b, i32 %n) nounwind readonly {
 
13
entry:
 
14
  %cmp1 = icmp sgt i32 %n, 0
 
15
  br i1 %cmp1, label %for.body.preheader, label %for.end
 
16
 
 
17
for.body.preheader:
 
18
  br label %for.body
 
19
 
 
20
for.body:                                         ; preds = %for.body.preheader, %for.body
 
21
  %sum.03 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]
 
22
  %arrayidx.phi = phi i32* [ %arrayidx.inc, %for.body ], [ %b, %for.body.preheader ]
 
23
  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
 
24
  %0 = load i32, i32* %arrayidx.phi, align 4
 
25
  %add = add nsw i32 %0, %sum.03
 
26
  %inc = add nsw i32 %i.02, 1
 
27
  %exitcond = icmp eq i32 %inc, %n
 
28
  %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
 
29
  br i1 %exitcond, label %for.end.loopexit, label %for.body
 
30
 
 
31
for.end.loopexit:
 
32
  br label %for.end
 
33
 
 
34
for.end:
 
35
  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.end.loopexit ]
 
36
  ret i32 %sum.0.lcssa
 
37
}
 
38
 
 
39
; This test checks that that initial loop count value is removed.
 
40
; CHECK-NOT: ={{.}}#40
 
41
; CHECK: loop0
 
42
; CHECK-NOT: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#-1)
 
43
; CHECK-NOT: cmp.eq
 
44
; CHECK: endloop0
 
45
 
 
46
define i32 @test2(i32* nocapture %b) nounwind readonly {
 
47
entry:
 
48
  br label %for.body
 
49
 
 
50
for.body:
 
51
  %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
 
52
  %arrayidx.phi = phi i32* [ %b, %entry ], [ %arrayidx.inc, %for.body ]
 
53
  %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
 
54
  %0 = load i32, i32* %arrayidx.phi, align 4
 
55
  %add = add nsw i32 %0, %sum.02
 
56
  %inc = add nsw i32 %i.01, 1
 
57
  %exitcond = icmp eq i32 %inc, 40
 
58
  %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
 
59
  br i1 %exitcond, label %for.end, label %for.body
 
60
 
 
61
for.end:
 
62
  ret i32 %add
 
63
}
 
64
 
 
65
; This test checks that we don't remove the induction variable since it's used.
 
66
; CHECK: loop0
 
67
; CHECK: r{{[0-9]+}}{{.}}={{.}}add(r{{[0-9]+}},{{.}}#1)
 
68
; CHECK-NOT: cmp.eq
 
69
; CHECK: endloop0
 
70
define i32 @test3(i32* nocapture %b) nounwind {
 
71
entry:
 
72
  br label %for.body
 
73
 
 
74
for.body:
 
75
  %arrayidx.phi = phi i32* [ %b, %entry ], [ %arrayidx.inc, %for.body ]
 
76
  %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
 
77
  store i32 %i.01, i32* %arrayidx.phi, align 4
 
78
  %inc = add nsw i32 %i.01, 1
 
79
  %exitcond = icmp eq i32 %inc, 40
 
80
  %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
 
81
  br i1 %exitcond, label %for.end, label %for.body
 
82
 
 
83
for.end:
 
84
  ret i32 0
 
85
}
 
86
 
 
87