Mercurial > hg > CbC > CbC_llvm
comparison polly/test/CodeGen/invariant_load_escaping.ll @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | |
children | 1f2b6ac9f198 |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
1 ; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -S < %s | FileCheck %s | |
2 ; | |
3 ; int f(int *A, int *B) { | |
4 ; // Possible aliasing between A and B but if not then *B would be | |
5 ; // invariant. We assume this and hoist *B but need to use a merged | |
6 ; // version in the return. | |
7 ; int i = 0; | |
8 ; int x = 0; | |
9 ; | |
10 ; do { | |
11 ; x = *B; | |
12 ; A[i] += x; | |
13 ; } while (i++ < 100); | |
14 ; | |
15 ; return x; | |
16 ; } | |
17 ; | |
18 ; CHECK: polly.preload.begin: | |
19 ; CHECK: %polly.access.B = getelementptr i32, i32* %B, i64 0 | |
20 ; CHECK: %polly.access.B.load = load i32, i32* %polly.access.B | |
21 ; CHECK: store i32 %polly.access.B.load, i32* %tmp.preload.s2a | |
22 ; | |
23 ; CHECK: polly.merge_new_and_old: | |
24 ; CHECK: %tmp.merge = phi i32 [ %tmp.final_reload, %polly.exiting ], [ %tmp, %do.cond ] | |
25 ; CHECK: br label %do.end | |
26 ; | |
27 ; CHECK: do.end: | |
28 ; CHECK: ret i32 %tmp.merge | |
29 ; | |
30 ; CHECK: polly.loop_exit: | |
31 ; CHECK: %tmp.final_reload = load i32, i32* %tmp.preload.s2a | |
32 ; | |
33 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | |
34 | |
35 define i32 @f(i32* %A, i32* %B) { | |
36 entry: | |
37 br label %do.body | |
38 | |
39 do.body: ; preds = %do.cond, %entry | |
40 %indvars.iv = phi i64 [ %indvars.iv.next, %do.cond ], [ 0, %entry ] | |
41 %tmp = load i32, i32* %B, align 4 | |
42 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv | |
43 %tmp1 = load i32, i32* %arrayidx, align 4 | |
44 %add = add nsw i32 %tmp1, %tmp | |
45 store i32 %add, i32* %arrayidx, align 4 | |
46 br label %do.cond | |
47 | |
48 do.cond: ; preds = %do.body | |
49 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 | |
50 %exitcond = icmp ne i64 %indvars.iv.next, 101 | |
51 br i1 %exitcond, label %do.body, label %do.end | |
52 | |
53 do.end: ; preds = %do.cond | |
54 ret i32 %tmp | |
55 } |