licm_reduction_nested.ll
2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
; RUN: opt %loadPolly -basic-aa -loop-rotate -indvars -polly-prepare -polly-scops -analyze < %s | FileCheck %s
; RUN: opt %loadPolly -basic-aa -loop-rotate -indvars -licm -polly-prepare -polly-scops -analyze < %s | FileCheck %s
;
; XFAIL: *
;
; Even ScopDetection fails here after LICM because of PHI in exit node.
;
; void foo(unsigned long *restrict A, unsigned long *restrict B,
; unsigned long j) {
; for (unsigned long i = 0; i < 100; i++)
; for (unsigned long k = 0; k < 100; k++)
; A[j] += B[i + k];
; }
;
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
define void @foo(i64* noalias %A, i64* noalias %B, i64 %j) {
entry:
br label %for.cond
for.cond: ; preds = %for.inc.6, %entry
%i.0 = phi i64 [ 0, %entry ], [ %inc7, %for.inc.6 ]
%exitcond1 = icmp ne i64 %i.0, 100
br i1 %exitcond1, label %for.body, label %for.end.8
for.body: ; preds = %for.cond
br label %for.cond.1
for.cond.1: ; preds = %for.inc, %for.body
%k.0 = phi i64 [ 0, %for.body ], [ %inc, %for.inc ]
%exitcond = icmp ne i64 %k.0, 100
br i1 %exitcond, label %for.body.3, label %for.end
for.body.3: ; preds = %for.cond.1
%add = add nuw nsw i64 %i.0, %k.0
%arrayidx = getelementptr inbounds i64, i64* %B, i64 %add
%tmp = load i64, i64* %arrayidx, align 8
%arrayidx4 = getelementptr inbounds i64, i64* %A, i64 %j
%tmp2 = load i64, i64* %arrayidx4, align 8
%add5 = add i64 %tmp2, %tmp
store i64 %add5, i64* %arrayidx4, align 8
br label %for.inc
for.inc: ; preds = %for.body.3
%inc = add nuw nsw i64 %k.0, 1
br label %for.cond.1
for.end: ; preds = %for.cond.1
br label %for.inc.6
for.inc.6: ; preds = %for.end
%inc7 = add nuw nsw i64 %i.0, 1
br label %for.cond
for.end.8: ; preds = %for.cond
ret void
}
; CHECK: Statements {
; CHECK: Stmt_for_body_3
; CHECK-DAG: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
; CHECK-NEXT: [j] -> { Stmt_for_body_3[i0, i1] -> MemRef_B[i0 + i1] };
; CHECK-DAG: ReadAccess := [Reduction Type: +] [Scalar: 0]
; CHECK-NEXT: [j] -> { Stmt_for_body_3[i0, i1] -> MemRef_A[j] };
; CHECK-DAG: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
; CHECK-NEXT: [j] -> { Stmt_for_body_3[i0, i1] -> MemRef_A[j] };
; CHECK: }