mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
1664c3c2ec
The delinearization is needed only to remove the non linearity induced by expressions involving multiplications of parameters and induction variables. There is no problem in dealing with constant times parameters, or constant times an induction variable. For this reason, the current patch discards all constant terms and multipliers before running the delinearization algorithm on the terms. The only thing remaining in the term expressions are parameters and multiply expressions of parameters: these simplified term expressions are passed to the array shape recognizer that will not recognize constant dimensions anymore: these will be recognized as different strides in parametric subscripts. The only important special case of a constant dimension is the size of elements. Instead of relying on the delinearization to infer the size of an element, compute the element size from the base address type. This is a much more precise way of computing the element size than before, as we would have mixed together the size of an element with the strides of the innermost dimension. llvm-svn: 209691
46 lines
1.2 KiB
LLVM
46 lines
1.2 KiB
LLVM
; RUN: opt < %s -analyze -delinearize | FileCheck %s
|
|
|
|
; Derived from the following code:
|
|
;
|
|
; void foo(long n, long m, long b, double A[n][m]) {
|
|
; for (long i = 0; i < n; i++)
|
|
; for (long j = 0; j < m; j++)
|
|
; A[2i+b][2j] = 1.0;
|
|
; }
|
|
|
|
; AddRec: {{((%m * %b * sizeof(double)) + %A),+,(2 * %m * sizeof(double))}<%for.i>,+,(2 * sizeof(double))}<%for.j>
|
|
; CHECK: Base offset: %A
|
|
; CHECK: ArrayDecl[UnknownSize][%m] with elements of sizeof(double) bytes.
|
|
; CHECK: ArrayRef[{%b,+,2}<%for.i>][{0,+,2}<%for.j>]
|
|
|
|
|
|
define void @foo(i64 %n, i64 %m, i64 %b, double* %A) {
|
|
entry:
|
|
br label %for.i
|
|
|
|
for.i:
|
|
%i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ]
|
|
%outerdim = mul nsw i64 %i, 2
|
|
%outerdim2 = add nsw i64 %outerdim, %b
|
|
%tmp = mul nsw i64 %outerdim2, %m
|
|
br label %for.j
|
|
|
|
for.j:
|
|
%j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j ]
|
|
%prodj = mul i64 %j, 2
|
|
%vlaarrayidx.sum = add i64 %prodj, %tmp
|
|
%arrayidx = getelementptr inbounds double* %A, i64 %vlaarrayidx.sum
|
|
store double 1.0, double* %arrayidx
|
|
%j.inc = add nsw i64 %j, 1
|
|
%j.exitcond = icmp eq i64 %j.inc, %m
|
|
br i1 %j.exitcond, label %for.i.inc, label %for.j
|
|
|
|
for.i.inc:
|
|
%i.inc = add nsw i64 %i, 1
|
|
%i.exitcond = icmp eq i64 %i.inc, %n
|
|
br i1 %i.exitcond, label %end, label %for.i
|
|
|
|
end:
|
|
ret void
|
|
}
|