llvm-project
75 строк · 2.4 Кб
1; RUN: opt %loadNPMPolly -passes=polly-codegen -S -verify-dom-info \
2; RUN: < %s | FileCheck %s
3;
4; Check that we do not reuse the B[i-1] GEP created in block S again in
5; block Q. Hence, we create two GEPs for B[i-1]:
6;
7; CHECK: %scevgep{{.}} = getelementptr i8, ptr %B, i64 -4
8; CHECK: %scevgep{{.}} = getelementptr i8, ptr %B, i64 -4
9;
10; void f(int *A, int *B) {
11; int x = 0;
12; for (int i = 0; i < 1024; i++) {
13; if (A[i]) {
14; if (i > 512)
15; S: A[i] = B[i - 1];
16; Q: A[i] += B[i - 1];
17; }
18; }
19; }
20;
21target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22
23define void @f(ptr %A, ptr %B) {
24bb:
25br label %bb1
26
27bb1: ; preds = %bb22, %bb
28%indvars.iv = phi i64 [ %indvars.iv.next, %bb22 ], [ 0, %bb ]
29%exitcond = icmp ne i64 %indvars.iv, 1024
30br i1 %exitcond, label %bb2, label %bb23
31
32bb2: ; preds = %bb1
33%tmp = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
34%tmp3 = load i32, ptr %tmp, align 4
35%tmp4 = icmp eq i32 %tmp3, 0
36br i1 %tmp4, label %bb21, label %bb5
37
38bb5: ; preds = %bb2
39%tmp6 = icmp sgt i64 %indvars.iv, 512
40br i1 %tmp6, label %bb7, label %bb13
41
42bb7: ; preds = %bb5
43br label %bb8
44
45bb8: ; preds = %bb7
46%tmp9 = add nsw i64 %indvars.iv, -1
47%tmp10 = getelementptr inbounds i32, ptr %B, i64 %tmp9
48%tmp11 = load i32, ptr %tmp10, align 4
49%tmp12 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
50store i32 %tmp11, ptr %tmp12, align 4
51br label %bb13
52
53bb13: ; preds = %bb8, %bb5
54br label %bb14
55
56bb14: ; preds = %bb13
57%tmp15 = add nsw i64 %indvars.iv, -1
58%tmp16 = getelementptr inbounds i32, ptr %B, i64 %tmp15
59%tmp17 = load i32, ptr %tmp16, align 4
60%tmp18 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
61%tmp19 = load i32, ptr %tmp18, align 4
62%tmp20 = add nsw i32 %tmp19, %tmp17
63store i32 %tmp20, ptr %tmp18, align 4
64br label %bb21
65
66bb21: ; preds = %bb2, %bb14
67br label %bb22
68
69bb22: ; preds = %bb21
70%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
71br label %bb1
72
73bb23: ; preds = %bb1
74ret void
75}
76