mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
93d67e228d
It's been quite some time the Dependence Analysis (DA) is broken, as it uses the GEP representation to "identify" multi-dimensional arrays. It even wrongly detects multi-dimensional arrays in single nested loops: from test/Analysis/DependenceAnalysis/Coupled.ll, example @couple6 ;; for (long int i = 0; i < 50; i++) { ;; A[i][3*i - 6] = i; ;; *B++ = A[i][i]; DA used to detect two subscripts, which makes no sense in the LLVM IR or in C/C++ semantics, as there are no guarantees as in Fortran of subscripts not overlapping into a next array dimension: maximum nesting levels = 1 SrcPtrSCEV = %A DstPtrSCEV = %A using GEPs subscript 0 src = {0,+,1}<nuw><nsw><%for.body> dst = {0,+,1}<nuw><nsw><%for.body> class = 1 loops = {1} subscript 1 src = {-6,+,3}<nsw><%for.body> dst = {0,+,1}<nuw><nsw><%for.body> class = 1 loops = {1} Separable = {} Coupled = {1} With the current patch, DA will correctly work on only one dimension: maximum nesting levels = 1 SrcSCEV = {(-2424 + %A)<nsw>,+,1212}<%for.body> DstSCEV = {%A,+,404}<%for.body> subscript 0 src = {(-2424 + %A)<nsw>,+,1212}<%for.body> dst = {%A,+,404}<%for.body> class = 1 loops = {1} Separable = {0} Coupled = {} This change removes all uses of GEP from DA, and we now only rely on the SCEV representation. The patch does not turn on -da-delinearize by default, and so the DA analysis will be more conservative in the case of multi-dimensional memory accesses in nested loops. I disabled some interchange tests, as the DA is not able to disambiguate the dependence anymore. To make DA stronger, we may need to compute a bound on the number of iterations based on the access functions and array dimensions. The patch cleans up all the CHECKs in test/Transforms/LoopInterchange/*.ll to avoid checking for snippets of LLVM IR: this form of checking is very hard to maintain. Instead, we now check for output of the pass that are more meaningful than dozens of lines of LLVM IR. Some tests now require -debug messages and thus only enabled with asserts. Patch written by Sebastian Pop and Aditya Kumar. Differential Revision: https://reviews.llvm.org/D35430 llvm-svn: 326837
42 lines
1.4 KiB
LLVM
42 lines
1.4 KiB
LLVM
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s
|
|
|
|
; Test for a bug, which caused an assert when an invalid
|
|
; SCEVAddRecExpr is created in addToCoefficient.
|
|
|
|
; CHECK-LABEL: foo
|
|
; CHECK: da analyze - consistent input [S 0]!
|
|
; CHECK: da analyze - input [* *|<]!
|
|
; CHECK: da analyze - none!
|
|
|
|
define float @foo(float %g, [40 x float]* %rr) nounwind {
|
|
entry:
|
|
br label %for.cond1.preheader
|
|
|
|
for.cond1.preheader:
|
|
%i.04 = phi i32 [ 0, %entry ], [ %add10, %for.inc9 ]
|
|
%res.03 = phi float [ 0.000000e+00, %entry ], [ %add.res.1, %for.inc9 ]
|
|
br label %for.body3
|
|
|
|
for.body3:
|
|
%j.02 = phi i32 [ 0, %for.cond1.preheader ], [ %add8, %for.body3 ]
|
|
%res.11 = phi float [ %res.03, %for.cond1.preheader ], [ %add.res.1, %for.body3 ]
|
|
%arrayidx4 = getelementptr inbounds [40 x float], [40 x float]* %rr, i32 %j.02, i32 %j.02
|
|
%0 = load float, float* %arrayidx4, align 4
|
|
%arrayidx6 = getelementptr inbounds [40 x float], [40 x float]* %rr, i32 %i.04, i32 %j.02
|
|
%1 = load float, float* %arrayidx6, align 4
|
|
%add = fadd float %0, %1
|
|
%cmp7 = fcmp ogt float %add, %g
|
|
%add.res.1 = select i1 %cmp7, float %add, float %res.11
|
|
%add8 = add nsw i32 %j.02, 5
|
|
%cmp2 = icmp slt i32 %add8, 40
|
|
br i1 %cmp2, label %for.body3, label %for.inc9
|
|
|
|
for.inc9:
|
|
%add10 = add nsw i32 %i.04, 5
|
|
%cmp = icmp slt i32 %add10, 40
|
|
br i1 %cmp, label %for.cond1.preheader, label %for.end11
|
|
|
|
for.end11:
|
|
ret float %add.res.1
|
|
}
|