mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-24 06:30:19 +00:00
ad43499fc4
Patch from Preston Briggs <preston.briggs@gmail.com>. This is an updated version of the dependence-analysis patch, including an MIV test based on Banerjee's inequalities. It's a fairly complete implementation of the paper Practical Dependence Testing Gina Goff, Ken Kennedy, and Chau-Wen Tseng PLDI 1991 It cannot yet propagate constraints between coupled RDIV subscripts (discussed in Section 5.3.2 of the paper). It's organized as a FunctionPass with a single entry point that supports testing for dependence between two instructions in a function. If there's no dependence, it returns null. If there's a dependence, it returns a pointer to a Dependence which can be queried about details (what kind of dependence, is it loop independent, direction and distance vector entries, etc). I haven't included every imaginable feature, but there's a good selection that should be adequate for supporting many loop transformations. Of course, it can be extended as necessary. Included in the patch file are many test cases, commented with C code showing the loops and array references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165708 91177308-0d34-0410-b5e6-96231b3b80d8
268 lines
11 KiB
LLVM
268 lines
11 KiB
LLVM
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
|
|
|
|
; ModuleID = 'Separability.bc'
|
|
target 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-S128"
|
|
target triple = "x86_64-apple-macosx10.6.0"
|
|
|
|
|
|
;; for (long int i = 0; i < 50; i++)
|
|
;; for (long int j = 0; j < 50; j++)
|
|
;; for (long int k = 0; k < 50; k++)
|
|
;; for (long int l = 0; l < 50; l++)
|
|
;; A[n][i][j + k] = ...
|
|
;; ... = A[10][i + 10][2*j - l];
|
|
|
|
define void @sep0([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
|
|
entry:
|
|
br label %for.cond1.preheader
|
|
|
|
for.cond1.preheader: ; preds = %for.inc22, %entry
|
|
%B.addr.08 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.inc22 ]
|
|
%i.07 = phi i64 [ 0, %entry ], [ %inc23, %for.inc22 ]
|
|
br label %for.cond4.preheader
|
|
|
|
for.cond4.preheader: ; preds = %for.inc19, %for.cond1.preheader
|
|
%B.addr.16 = phi i32* [ %B.addr.08, %for.cond1.preheader ], [ %incdec.ptr, %for.inc19 ]
|
|
%j.05 = phi i64 [ 0, %for.cond1.preheader ], [ %inc20, %for.inc19 ]
|
|
br label %for.cond7.preheader
|
|
|
|
for.cond7.preheader: ; preds = %for.inc16, %for.cond4.preheader
|
|
%B.addr.24 = phi i32* [ %B.addr.16, %for.cond4.preheader ], [ %incdec.ptr, %for.inc16 ]
|
|
%k.03 = phi i64 [ 0, %for.cond4.preheader ], [ %inc17, %for.inc16 ]
|
|
br label %for.body9
|
|
|
|
for.body9: ; preds = %for.body9, %for.cond7.preheader
|
|
%l.02 = phi i64 [ 0, %for.cond7.preheader ], [ %inc, %for.body9 ]
|
|
%B.addr.31 = phi i32* [ %B.addr.24, %for.cond7.preheader ], [ %incdec.ptr, %for.body9 ]
|
|
%conv = trunc i64 %i.07 to i32
|
|
%add = add nsw i64 %j.05, %k.03
|
|
%idxprom = sext i32 %n to i64
|
|
%arrayidx11 = getelementptr inbounds [100 x [100 x i32]]* %A, i64 %idxprom, i64 %i.07, i64 %add
|
|
store i32 %conv, i32* %arrayidx11, align 4
|
|
%mul = shl nsw i64 %j.05, 1
|
|
%sub = sub nsw i64 %mul, %l.02
|
|
%add12 = add nsw i64 %i.07, 10
|
|
%arrayidx15 = getelementptr inbounds [100 x [100 x i32]]* %A, i64 10, i64 %add12, i64 %sub
|
|
%0 = load i32* %arrayidx15, align 4
|
|
; CHECK: da analyze - flow [-10 * * *]!
|
|
%incdec.ptr = getelementptr inbounds i32* %B.addr.31, i64 1
|
|
store i32 %0, i32* %B.addr.31, align 4
|
|
%inc = add nsw i64 %l.02, 1
|
|
%cmp8 = icmp slt i64 %inc, 50
|
|
br i1 %cmp8, label %for.body9, label %for.inc16
|
|
|
|
for.inc16: ; preds = %for.body9
|
|
%inc17 = add nsw i64 %k.03, 1
|
|
%cmp5 = icmp slt i64 %inc17, 50
|
|
br i1 %cmp5, label %for.cond7.preheader, label %for.inc19
|
|
|
|
for.inc19: ; preds = %for.inc16
|
|
%inc20 = add nsw i64 %j.05, 1
|
|
%cmp2 = icmp slt i64 %inc20, 50
|
|
br i1 %cmp2, label %for.cond4.preheader, label %for.inc22
|
|
|
|
for.inc22: ; preds = %for.inc19
|
|
%inc23 = add nsw i64 %i.07, 1
|
|
%cmp = icmp slt i64 %inc23, 50
|
|
br i1 %cmp, label %for.cond1.preheader, label %for.end24
|
|
|
|
for.end24: ; preds = %for.inc22
|
|
ret void
|
|
}
|
|
|
|
|
|
;; for (long int i = 0; i < 50; i++)
|
|
;; for (long int j = 0; j < 50; j++)
|
|
;; for (long int k = 0; k < 50; k++)
|
|
;; for (long int l = 0; l < 50; l++)
|
|
;; A[i][i][j + k] = ...
|
|
;; ... = A[10][i + 10][2*j - l];
|
|
|
|
define void @sep1([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
|
|
entry:
|
|
br label %for.cond1.preheader
|
|
|
|
for.cond1.preheader: ; preds = %for.inc22, %entry
|
|
%B.addr.08 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.inc22 ]
|
|
%i.07 = phi i64 [ 0, %entry ], [ %inc23, %for.inc22 ]
|
|
br label %for.cond4.preheader
|
|
|
|
for.cond4.preheader: ; preds = %for.inc19, %for.cond1.preheader
|
|
%B.addr.16 = phi i32* [ %B.addr.08, %for.cond1.preheader ], [ %incdec.ptr, %for.inc19 ]
|
|
%j.05 = phi i64 [ 0, %for.cond1.preheader ], [ %inc20, %for.inc19 ]
|
|
br label %for.cond7.preheader
|
|
|
|
for.cond7.preheader: ; preds = %for.inc16, %for.cond4.preheader
|
|
%B.addr.24 = phi i32* [ %B.addr.16, %for.cond4.preheader ], [ %incdec.ptr, %for.inc16 ]
|
|
%k.03 = phi i64 [ 0, %for.cond4.preheader ], [ %inc17, %for.inc16 ]
|
|
br label %for.body9
|
|
|
|
for.body9: ; preds = %for.body9, %for.cond7.preheader
|
|
%l.02 = phi i64 [ 0, %for.cond7.preheader ], [ %inc, %for.body9 ]
|
|
%B.addr.31 = phi i32* [ %B.addr.24, %for.cond7.preheader ], [ %incdec.ptr, %for.body9 ]
|
|
%conv = trunc i64 %i.07 to i32
|
|
%add = add nsw i64 %j.05, %k.03
|
|
%arrayidx11 = getelementptr inbounds [100 x [100 x i32]]* %A, i64 %i.07, i64 %i.07, i64 %add
|
|
store i32 %conv, i32* %arrayidx11, align 4
|
|
%mul = shl nsw i64 %j.05, 1
|
|
%sub = sub nsw i64 %mul, %l.02
|
|
%add12 = add nsw i64 %i.07, 10
|
|
%arrayidx15 = getelementptr inbounds [100 x [100 x i32]]* %A, i64 10, i64 %add12, i64 %sub
|
|
%0 = load i32* %arrayidx15, align 4
|
|
; CHECK: da analyze - flow [> * * *]!
|
|
%incdec.ptr = getelementptr inbounds i32* %B.addr.31, i64 1
|
|
store i32 %0, i32* %B.addr.31, align 4
|
|
%inc = add nsw i64 %l.02, 1
|
|
%cmp8 = icmp slt i64 %inc, 50
|
|
br i1 %cmp8, label %for.body9, label %for.inc16
|
|
|
|
for.inc16: ; preds = %for.body9
|
|
%inc17 = add nsw i64 %k.03, 1
|
|
%cmp5 = icmp slt i64 %inc17, 50
|
|
br i1 %cmp5, label %for.cond7.preheader, label %for.inc19
|
|
|
|
for.inc19: ; preds = %for.inc16
|
|
%inc20 = add nsw i64 %j.05, 1
|
|
%cmp2 = icmp slt i64 %inc20, 50
|
|
br i1 %cmp2, label %for.cond4.preheader, label %for.inc22
|
|
|
|
for.inc22: ; preds = %for.inc19
|
|
%inc23 = add nsw i64 %i.07, 1
|
|
%cmp = icmp slt i64 %inc23, 50
|
|
br i1 %cmp, label %for.cond1.preheader, label %for.end24
|
|
|
|
for.end24: ; preds = %for.inc22
|
|
ret void
|
|
}
|
|
|
|
|
|
;; for (long int i = 0; i < 50; i++)
|
|
;; for (long int j = 0; j < 50; j++)
|
|
;; for (long int k = 0; k < 50; k++)
|
|
;; for (long int l = 0; l < 50; l++)
|
|
;; A[i][i][i + k][l] = ...
|
|
;; ... = A[10][i + 10][j + k][l + 10];
|
|
|
|
define void @sep2([100 x [100 x [100 x i32]]]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
|
|
entry:
|
|
br label %for.cond1.preheader
|
|
|
|
for.cond1.preheader: ; preds = %for.inc26, %entry
|
|
%B.addr.08 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.inc26 ]
|
|
%i.07 = phi i64 [ 0, %entry ], [ %inc27, %for.inc26 ]
|
|
br label %for.cond4.preheader
|
|
|
|
for.cond4.preheader: ; preds = %for.inc23, %for.cond1.preheader
|
|
%B.addr.16 = phi i32* [ %B.addr.08, %for.cond1.preheader ], [ %incdec.ptr, %for.inc23 ]
|
|
%j.05 = phi i64 [ 0, %for.cond1.preheader ], [ %inc24, %for.inc23 ]
|
|
br label %for.cond7.preheader
|
|
|
|
for.cond7.preheader: ; preds = %for.inc20, %for.cond4.preheader
|
|
%B.addr.24 = phi i32* [ %B.addr.16, %for.cond4.preheader ], [ %incdec.ptr, %for.inc20 ]
|
|
%k.03 = phi i64 [ 0, %for.cond4.preheader ], [ %inc21, %for.inc20 ]
|
|
br label %for.body9
|
|
|
|
for.body9: ; preds = %for.body9, %for.cond7.preheader
|
|
%l.02 = phi i64 [ 0, %for.cond7.preheader ], [ %inc, %for.body9 ]
|
|
%B.addr.31 = phi i32* [ %B.addr.24, %for.cond7.preheader ], [ %incdec.ptr, %for.body9 ]
|
|
%conv = trunc i64 %i.07 to i32
|
|
%add = add nsw i64 %i.07, %k.03
|
|
%arrayidx12 = getelementptr inbounds [100 x [100 x [100 x i32]]]* %A, i64 %i.07, i64 %i.07, i64 %add, i64 %l.02
|
|
store i32 %conv, i32* %arrayidx12, align 4
|
|
%add13 = add nsw i64 %l.02, 10
|
|
%add14 = add nsw i64 %j.05, %k.03
|
|
%add15 = add nsw i64 %i.07, 10
|
|
%arrayidx19 = getelementptr inbounds [100 x [100 x [100 x i32]]]* %A, i64 10, i64 %add15, i64 %add14, i64 %add13
|
|
%0 = load i32* %arrayidx19, align 4
|
|
; CHECK: da analyze - flow [> * * -10]!
|
|
%incdec.ptr = getelementptr inbounds i32* %B.addr.31, i64 1
|
|
store i32 %0, i32* %B.addr.31, align 4
|
|
%inc = add nsw i64 %l.02, 1
|
|
%cmp8 = icmp slt i64 %inc, 50
|
|
br i1 %cmp8, label %for.body9, label %for.inc20
|
|
|
|
for.inc20: ; preds = %for.body9
|
|
%inc21 = add nsw i64 %k.03, 1
|
|
%cmp5 = icmp slt i64 %inc21, 50
|
|
br i1 %cmp5, label %for.cond7.preheader, label %for.inc23
|
|
|
|
for.inc23: ; preds = %for.inc20
|
|
%inc24 = add nsw i64 %j.05, 1
|
|
%cmp2 = icmp slt i64 %inc24, 50
|
|
br i1 %cmp2, label %for.cond4.preheader, label %for.inc26
|
|
|
|
for.inc26: ; preds = %for.inc23
|
|
%inc27 = add nsw i64 %i.07, 1
|
|
%cmp = icmp slt i64 %inc27, 50
|
|
br i1 %cmp, label %for.cond1.preheader, label %for.end28
|
|
|
|
for.end28: ; preds = %for.inc26
|
|
ret void
|
|
}
|
|
|
|
|
|
;; for (long int i = 0; i < 50; i++)
|
|
;; for (long int j = 0; j < 50; j++)
|
|
;; for (long int k = 0; k < 50; k++)
|
|
;; for (long int l = 0; l < 50; l++)
|
|
;; A[i][i][i + k][l + k] = ...
|
|
;; ... = A[10][i + 10][j + k][l + 10];
|
|
|
|
define void @sep3([100 x [100 x [100 x i32]]]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
|
|
entry:
|
|
br label %for.cond1.preheader
|
|
|
|
for.cond1.preheader: ; preds = %for.inc27, %entry
|
|
%B.addr.08 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.inc27 ]
|
|
%i.07 = phi i64 [ 0, %entry ], [ %inc28, %for.inc27 ]
|
|
br label %for.cond4.preheader
|
|
|
|
for.cond4.preheader: ; preds = %for.inc24, %for.cond1.preheader
|
|
%B.addr.16 = phi i32* [ %B.addr.08, %for.cond1.preheader ], [ %incdec.ptr, %for.inc24 ]
|
|
%j.05 = phi i64 [ 0, %for.cond1.preheader ], [ %inc25, %for.inc24 ]
|
|
br label %for.cond7.preheader
|
|
|
|
for.cond7.preheader: ; preds = %for.inc21, %for.cond4.preheader
|
|
%B.addr.24 = phi i32* [ %B.addr.16, %for.cond4.preheader ], [ %incdec.ptr, %for.inc21 ]
|
|
%k.03 = phi i64 [ 0, %for.cond4.preheader ], [ %inc22, %for.inc21 ]
|
|
br label %for.body9
|
|
|
|
for.body9: ; preds = %for.body9, %for.cond7.preheader
|
|
%l.02 = phi i64 [ 0, %for.cond7.preheader ], [ %inc, %for.body9 ]
|
|
%B.addr.31 = phi i32* [ %B.addr.24, %for.cond7.preheader ], [ %incdec.ptr, %for.body9 ]
|
|
%conv = trunc i64 %i.07 to i32
|
|
%add = add nsw i64 %l.02, %k.03
|
|
%add10 = add nsw i64 %i.07, %k.03
|
|
%arrayidx13 = getelementptr inbounds [100 x [100 x [100 x i32]]]* %A, i64 %i.07, i64 %i.07, i64 %add10, i64 %add
|
|
store i32 %conv, i32* %arrayidx13, align 4
|
|
%add14 = add nsw i64 %l.02, 10
|
|
%add15 = add nsw i64 %j.05, %k.03
|
|
%add16 = add nsw i64 %i.07, 10
|
|
%arrayidx20 = getelementptr inbounds [100 x [100 x [100 x i32]]]* %A, i64 10, i64 %add16, i64 %add15, i64 %add14
|
|
%0 = load i32* %arrayidx20, align 4
|
|
; CHECK: da analyze - flow [> * * *]!
|
|
%incdec.ptr = getelementptr inbounds i32* %B.addr.31, i64 1
|
|
store i32 %0, i32* %B.addr.31, align 4
|
|
%inc = add nsw i64 %l.02, 1
|
|
%cmp8 = icmp slt i64 %inc, 50
|
|
br i1 %cmp8, label %for.body9, label %for.inc21
|
|
|
|
for.inc21: ; preds = %for.body9
|
|
%inc22 = add nsw i64 %k.03, 1
|
|
%cmp5 = icmp slt i64 %inc22, 50
|
|
br i1 %cmp5, label %for.cond7.preheader, label %for.inc24
|
|
|
|
for.inc24: ; preds = %for.inc21
|
|
%inc25 = add nsw i64 %j.05, 1
|
|
%cmp2 = icmp slt i64 %inc25, 50
|
|
br i1 %cmp2, label %for.cond4.preheader, label %for.inc27
|
|
|
|
for.inc27: ; preds = %for.inc24
|
|
%inc28 = add nsw i64 %i.07, 1
|
|
%cmp = icmp slt i64 %inc28, 50
|
|
br i1 %cmp, label %for.cond1.preheader, label %for.end29
|
|
|
|
for.end29: ; preds = %for.inc27
|
|
ret void
|
|
}
|