llvm-project
55 строк · 1.7 Кб
1; RUN: opt -S %loadNPMPolly -aa-pipeline=basic-aa -polly-dependences-analysis-type=value-based '-passes=polly-dce,print<polly-ast>' -disable-output < %s | FileCheck %s -check-prefix=CHECK-DCE
2target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
3; A[0] = 1;
4;
5; for(i = 0; i < 100; i++ )
6; A[i+1] = A[i] * 2;
7;
8; for (i = 0; i < 200; i++ )
9; A[i] = B[i] * 2;
10
11define void @main() nounwind uwtable {
12
13entry:
14%A = alloca [200 x i32], align 16
15%B = alloca [200 x i32], align 16
16
17store i32 1, ptr %A, align 4
18
19br label %for.body.1
20
21for.body.1:
22%indvar.1 = phi i64 [ 0, %entry ], [ %indvar.next.1, %for.body.1 ]
23%indvar.next.1 = add i64 %indvar.1, 1
24
25%A.current.1 = getelementptr [200 x i32], ptr %A, i64 0, i64 %indvar.1
26%val1.1 = load i32, ptr %A.current.1, align 4
27%val2.1 = mul i32 %val1.1, 2
28%A.next.1 = getelementptr [200 x i32], ptr %A, i64 0, i64 %indvar.next.1
29store i32 %val2.1, ptr %A.next.1, align 4
30
31%exitcond.1 = icmp ne i64 %indvar.next.1, 100
32br i1 %exitcond.1, label %for.body.1, label %exit.1
33
34exit.1:
35br label %for.body.2
36
37for.body.2:
38%indvar.2 = phi i64 [ 0, %exit.1 ], [ %indvar.next.2, %for.body.2 ]
39
40%B.current.2 = getelementptr [200 x i32], ptr %B, i64 0, i64 %indvar.2
41%val1.2 = load i32, ptr %B.current.2, align 4
42%val2.2 = mul i32 %val1.2, 2
43%A.current.2 = getelementptr [200 x i32], ptr %A, i64 0, i64 %indvar.2
44store i32 %val2.2, ptr %A.current.2, align 4
45
46%indvar.next.2 = add i64 %indvar.2, 1
47%exitcond.2 = icmp ne i64 %indvar.next.2, 200
48br i1 %exitcond.2, label %for.body.2, label %exit.3
49
50exit.3:
51ret void
52}
53
54; CHECK-DCE: for (int c0 = 0; c0 <= 199; c0 += 1)
55; CHECK-DCE: Stmt_for_body_2(c0);
56