llvm-project
69 строк · 2.0 Кб
1; RUN: opt %loadNPMPolly -passes=polly-codegen -polly-invariant-load-hoisting=true -polly-process-unprofitable -S < %s | FileCheck %s
2;
3; void fence(void);
4;
5; void f(int *A, int *B) {
6; int i = 0;
7; int x = 0;
8;
9; do {
10; x = *B;
11; S: A[i] += x;
12; } while (i++ < 100);
13;
14; fence();
15;
16; do {
17; P: A[i]++;
18; } while (i++ < x / 2);
19; }
20;
21; CHECK: polly.stmt.stmt.P:
22; CHECK: sext i32 %tmp.merge to i64
23;
24target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
25
26define void @f(ptr %A, ptr %B) {
27entry:
28br label %stmt.S
29
30stmt.S: ; preds = %do.cond, %entry
31%indvars.iv2 = phi i64 [ %indvars.iv.next3, %do.cond ], [ 0, %entry ]
32%tmp = load i32, ptr %B, align 4
33%arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv2
34%tmp4 = load i32, ptr %arrayidx, align 4
35%add = add nsw i32 %tmp4, %tmp
36store i32 %add, ptr %arrayidx, align 4
37br label %do.cond
38
39do.cond: ; preds = %do.body
40%indvars.iv.next3 = add nuw nsw i64 %indvars.iv2, 1
41%exitcond = icmp ne i64 %indvars.iv.next3, 101
42br i1 %exitcond, label %stmt.S, label %do.end
43
44do.end: ; preds = %do.cond
45%tmp5 = trunc i64 101 to i32
46call void @fence() #2
47%tmp6 = sext i32 %tmp5 to i64
48br label %stmt.P
49
50stmt.P: ; preds = %do.cond.5, %do.end
51%indvars.iv = phi i64 [ %indvars.iv.next, %do.cond.5 ], [ %tmp6, %do.end ]
52%arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
53%tmp7 = load i32, ptr %arrayidx3, align 4
54%inc4 = add nsw i32 %tmp7, 1
55store i32 %inc4, ptr %arrayidx3, align 4
56br label %do.cond.5
57
58do.cond.5: ; preds = %do.body.1
59%div = sdiv i32 %tmp, 2
60%tmp8 = sext i32 %div to i64
61%cmp7 = icmp slt i64 %indvars.iv, %tmp8
62%indvars.iv.next = add i64 %indvars.iv, 1
63br i1 %cmp7, label %stmt.P, label %do.end.8
64
65do.end.8: ; preds = %do.cond.5
66ret void
67}
68
69declare void @fence()
70