1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

DA: remove uses of GEP, only ask SCEV

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
This commit is contained in:
Sebastian Pop 2018-03-06 21:55:59 +00:00
parent fec534d1ac
commit 93d67e228d
30 changed files with 515 additions and 1105 deletions

View File

@ -24,8 +24,7 @@
// Both of these are conservative weaknesses;
// that is, not a source of correctness problems.
//
// The implementation depends on the GEP instruction to differentiate
// subscripts. Since Clang linearizes some array subscripts, the dependence
// Since Clang linearizes some array subscripts, the dependence
// analysis is using SCEV->delinearize to recover the representation of multiple
// subscripts, and thus avoid the more expensive and less precise MIV tests. The
// delinearization is controlled by the flag -da-delinearize.
@ -3329,50 +3328,18 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
FullDependence Result(Src, Dst, PossiblyLoopIndependent, CommonLevels);
++TotalArrayPairs;
// See if there are GEPs we can use.
bool UsefulGEP = false;
GEPOperator *SrcGEP = dyn_cast<GEPOperator>(SrcPtr);
GEPOperator *DstGEP = dyn_cast<GEPOperator>(DstPtr);
if (SrcGEP && DstGEP &&
SrcGEP->getPointerOperandType() == DstGEP->getPointerOperandType()) {
const SCEV *SrcPtrSCEV = SE->getSCEV(SrcGEP->getPointerOperand());
const SCEV *DstPtrSCEV = SE->getSCEV(DstGEP->getPointerOperand());
DEBUG(dbgs() << " SrcPtrSCEV = " << *SrcPtrSCEV << "\n");
DEBUG(dbgs() << " DstPtrSCEV = " << *DstPtrSCEV << "\n");
UsefulGEP = isLoopInvariant(SrcPtrSCEV, LI->getLoopFor(Src->getParent())) &&
isLoopInvariant(DstPtrSCEV, LI->getLoopFor(Dst->getParent())) &&
(SrcGEP->getNumOperands() == DstGEP->getNumOperands()) &&
isKnownPredicate(CmpInst::ICMP_EQ, SrcPtrSCEV, DstPtrSCEV);
}
unsigned Pairs = UsefulGEP ? SrcGEP->idx_end() - SrcGEP->idx_begin() : 1;
SmallVector<Subscript, 4> Pair(Pairs);
if (UsefulGEP) {
DEBUG(dbgs() << " using GEPs\n");
unsigned P = 0;
for (GEPOperator::const_op_iterator SrcIdx = SrcGEP->idx_begin(),
SrcEnd = SrcGEP->idx_end(),
DstIdx = DstGEP->idx_begin();
SrcIdx != SrcEnd;
++SrcIdx, ++DstIdx, ++P) {
Pair[P].Src = SE->getSCEV(*SrcIdx);
Pair[P].Dst = SE->getSCEV(*DstIdx);
unifySubscriptType(&Pair[P]);
}
}
else {
DEBUG(dbgs() << " ignoring GEPs\n");
unsigned Pairs = 1;
SmallVector<Subscript, 2> Pair(Pairs);
const SCEV *SrcSCEV = SE->getSCEV(SrcPtr);
const SCEV *DstSCEV = SE->getSCEV(DstPtr);
DEBUG(dbgs() << " SrcSCEV = " << *SrcSCEV << "\n");
DEBUG(dbgs() << " DstSCEV = " << *DstSCEV << "\n");
Pair[0].Src = SrcSCEV;
Pair[0].Dst = DstSCEV;
}
if (Delinearize && CommonLevels > 1) {
if (Delinearize) {
if (tryDelinearize(Src, Dst, Pair)) {
DEBUG(dbgs() << " delinearized GEP\n");
DEBUG(dbgs() << " delinearized\n");
Pairs = Pair.size();
}
}
@ -3763,41 +3730,16 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
FullDependence Result(Src, Dst, false, CommonLevels);
// See if there are GEPs we can use.
bool UsefulGEP = false;
GEPOperator *SrcGEP = dyn_cast<GEPOperator>(SrcPtr);
GEPOperator *DstGEP = dyn_cast<GEPOperator>(DstPtr);
if (SrcGEP && DstGEP &&
SrcGEP->getPointerOperandType() == DstGEP->getPointerOperandType()) {
const SCEV *SrcPtrSCEV = SE->getSCEV(SrcGEP->getPointerOperand());
const SCEV *DstPtrSCEV = SE->getSCEV(DstGEP->getPointerOperand());
UsefulGEP = isLoopInvariant(SrcPtrSCEV, LI->getLoopFor(Src->getParent())) &&
isLoopInvariant(DstPtrSCEV, LI->getLoopFor(Dst->getParent())) &&
(SrcGEP->getNumOperands() == DstGEP->getNumOperands());
}
unsigned Pairs = UsefulGEP ? SrcGEP->idx_end() - SrcGEP->idx_begin() : 1;
SmallVector<Subscript, 4> Pair(Pairs);
if (UsefulGEP) {
unsigned P = 0;
for (GEPOperator::const_op_iterator SrcIdx = SrcGEP->idx_begin(),
SrcEnd = SrcGEP->idx_end(),
DstIdx = DstGEP->idx_begin();
SrcIdx != SrcEnd;
++SrcIdx, ++DstIdx, ++P) {
Pair[P].Src = SE->getSCEV(*SrcIdx);
Pair[P].Dst = SE->getSCEV(*DstIdx);
}
}
else {
unsigned Pairs = 1;
SmallVector<Subscript, 2> Pair(Pairs);
const SCEV *SrcSCEV = SE->getSCEV(SrcPtr);
const SCEV *DstSCEV = SE->getSCEV(DstPtr);
Pair[0].Src = SrcSCEV;
Pair[0].Dst = DstSCEV;
}
if (Delinearize && CommonLevels > 1) {
if (Delinearize) {
if (tryDelinearize(Src, Dst, Pair)) {
DEBUG(dbgs() << " delinearized GEP\n");
DEBUG(dbgs() << " delinearized\n");
Pairs = Pair.size();
}
}

View File

@ -591,13 +591,13 @@ struct LoopInterchange : public FunctionPass {
LoopInterchangeLegality LIL(OuterLoop, InnerLoop, SE, LI, DT,
PreserveLCSSA, ORE);
if (!LIL.canInterchangeLoops(InnerLoopId, OuterLoopId, DependencyMatrix)) {
DEBUG(dbgs() << "Not interchanging Loops. Cannot prove legality\n");
DEBUG(dbgs() << "Not interchanging loops. Cannot prove legality.\n");
return false;
}
DEBUG(dbgs() << "Loops are legal to interchange\n");
LoopInterchangeProfitability LIP(OuterLoop, InnerLoop, SE, ORE);
if (!LIP.isProfitable(InnerLoopId, OuterLoopId, DependencyMatrix)) {
DEBUG(dbgs() << "Interchanging loops not profitable\n");
DEBUG(dbgs() << "Interchanging loops not profitable.\n");
return false;
}
@ -611,7 +611,7 @@ struct LoopInterchange : public FunctionPass {
LoopInterchangeTransform LIT(OuterLoop, InnerLoop, SE, LI, DT,
LoopNestExit, LIL.hasInnerLoopReduction());
LIT.transform();
DEBUG(dbgs() << "Loops interchanged\n");
DEBUG(dbgs() << "Loops interchanged.\n");
return true;
}
};

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s
; ModuleID = 'Coupled.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"
@ -13,6 +13,7 @@ define void @couple0([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple0
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -49,6 +50,7 @@ define void @couple1([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple1
; CHECK: da analyze - none!
; CHECK: da analyze - consistent flow [-9]!
; CHECK: da analyze - confused!
@ -85,8 +87,9 @@ define void @couple2([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple2
; CHECK: da analyze - none!
; CHECK: da analyze - flow [*|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -123,6 +126,7 @@ define void @couple3([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple3
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -161,6 +165,7 @@ define void @couple4([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple4
; CHECK: da analyze - none!
; CHECK: da analyze - flow [*|<]!
; CHECK: da analyze - confused!
@ -200,6 +205,7 @@ define void @couple5([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple5
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -241,8 +247,9 @@ define void @couple6([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple6
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -277,6 +284,7 @@ define void @couple7([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple7
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -313,6 +321,7 @@ define void @couple8([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple8
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -350,6 +359,7 @@ define void @couple9([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple9
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -387,9 +397,9 @@ define void @couple10([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple10
; CHECK: da analyze - none!
; CHECK: da analyze - flow [>] splitable!
; CHECK: da analyze - split level = 1, iteration = 3!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -425,9 +435,9 @@ define void @couple11([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple11
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=|<] splitable!
; CHECK: da analyze - split level = 1, iteration = 9!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -463,9 +473,9 @@ define void @couple12([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple12
; CHECK: da analyze - none!
; CHECK: da analyze - flow [<] splitable!
; CHECK: da analyze - split level = 1, iteration = 11!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -501,6 +511,7 @@ define void @couple13([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: couple13
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -537,9 +548,9 @@ define void @couple14([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable
entry:
br label %for.body
; CHECK-LABEL: couple14
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=|<] splitable!
; CHECK: da analyze - split level = 1, iteration = 9!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -575,6 +586,7 @@ define void @couple15([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable
entry:
br label %for.body
; CHECK-LABEL: couple15
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s
; ModuleID = 'ExactSIV.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"
@ -13,8 +13,9 @@ define void @exact0(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact0
; CHECK: da analyze - none!
; CHECK: da analyze - flow [<=|<]!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -50,6 +51,7 @@ define void @exact1(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact1
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -88,6 +90,7 @@ define void @exact2(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact2
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -124,8 +127,9 @@ define void @exact3(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact3
; CHECK: da analyze - none!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -160,8 +164,9 @@ define void @exact4(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact4
; CHECK: da analyze - none!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -196,8 +201,9 @@ define void @exact5(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact5
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=>|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -232,8 +238,9 @@ define void @exact6(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact6
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=>|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -268,8 +275,9 @@ define void @exact7(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact7
; CHECK: da analyze - none!
; CHECK: da analyze - flow [*|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -304,6 +312,7 @@ define void @exact8(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact8
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -340,8 +349,9 @@ define void @exact9(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact9
; CHECK: da analyze - none!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -376,8 +386,9 @@ define void @exact10(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact10
; CHECK: da analyze - none!
; CHECK: da analyze - flow [>]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -412,8 +423,9 @@ define void @exact11(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact11
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=>|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -448,8 +460,9 @@ define void @exact12(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact12
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=>|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -484,8 +497,9 @@ define void @exact13(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.body
; CHECK-LABEL: exact13
; CHECK: da analyze - none!
; CHECK: da analyze - flow [*|<]!
; CHECK: da analyze - flow [<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!

View File

@ -1,4 +1,3 @@
; RUN: opt < %s -analyze -basicaa -da -da-delinearize=false | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s -check-prefix=DELIN
; ModuleID = 'GCD.bc'
@ -15,15 +14,7 @@ define void @gcd0(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK: 'Dependence Analysis' for function 'gcd0'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - flow [=> *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd0'
; DELIN-LABEL: gcd0
; DELIN: da analyze - output [* *]!
; DELIN: da analyze - flow [=> *|<]!
; DELIN: da analyze - confused!
@ -76,15 +67,7 @@ define void @gcd1(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK: 'Dependence Analysis' for function 'gcd1'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd1'
; DELIN-LABEL: gcd1
; DELIN: da analyze - output [* *]!
; DELIN: da analyze - none!
; DELIN: da analyze - confused!
@ -138,15 +121,7 @@ define void @gcd2(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK: 'Dependence Analysis' for function 'gcd2'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd2'
; DELIN-LABEL: gcd2
; DELIN: da analyze - output [* *]!
; DELIN: da analyze - none!
; DELIN: da analyze - confused!
@ -200,15 +175,7 @@ define void @gcd3(i32* %A, i32* %B) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK: 'Dependence Analysis' for function 'gcd3'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - flow [<> *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd3'
; DELIN-LABEL: gcd3
; DELIN: da analyze - output [* *]!
; DELIN: da analyze - flow [<> *]!
; DELIN: da analyze - confused!
@ -260,15 +227,7 @@ define void @gcd4(i32* %A, i32* %B, i64 %M, i64 %N) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK: 'Dependence Analysis' for function 'gcd4'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd4'
; DELIN-LABEL: gcd4
; DELIN: da analyze - none!
; DELIN: da analyze - none!
; DELIN: da analyze - confused!
@ -330,15 +289,7 @@ define void @gcd5(i32* %A, i32* %B, i64 %M, i64 %N) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK: 'Dependence Analysis' for function 'gcd5'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - flow [<> *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd5'
; DELIN-LABEL: gcd5
; DELIN: da analyze - none!
; DELIN: da analyze - flow [> *]!
; DELIN: da analyze - confused!
@ -401,15 +352,7 @@ entry:
%cmp4 = icmp sgt i64 %n, 0
br i1 %cmp4, label %for.cond1.preheader.preheader, label %for.end12
; CHECK: 'Dependence Analysis' for function 'gcd6'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - output [* *]!
; DELIN: 'Dependence Analysis' for function 'gcd6'
; DELIN-LABEL: gcd6
; DELIN: da analyze - none!
; DELIN: da analyze - none!
; DELIN: da analyze - confused!
@ -481,15 +424,7 @@ entry:
%cmp4 = icmp sgt i32 %n, 0
br i1 %cmp4, label %for.cond1.preheader.preheader, label %for.end15
; CHECK: 'Dependence Analysis' for function 'gcd7'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - flow [* *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - output [* *]!
; DELIN: 'Dependence Analysis' for function 'gcd7'
; DELIN-LABEL: gcd7
; DELIN: da analyze - output [* *]!
; DELIN: da analyze - flow [* *|<]!
; DELIN: da analyze - confused!
@ -573,17 +508,9 @@ entry:
%cmp4 = icmp sgt i32 %n, 0
br i1 %cmp4, label %for.cond1.preheader.preheader, label %for.end15
; CHECK: 'Dependence Analysis' for function 'gcd8'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - output [* *]!
; DELIN: 'Dependence Analysis' for function 'gcd8'
; DELIN-LABEL: gcd8
; DELIN: da analyze - output [* *]!
; DELIN: da analyze - none!
; DELIN: da analyze - flow [* *|<]!
; DELIN: da analyze - confused!
; DELIN: da analyze - input [* *]!
; DELIN: da analyze - confused!
@ -660,15 +587,7 @@ entry:
%cmp4 = icmp eq i32 %n, 0
br i1 %cmp4, label %for.end15, label %for.cond1.preheader.preheader
; CHECK: 'Dependence Analysis' for function 'gcd9'
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - flow [* *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - output [* *]!
; DELIN: 'Dependence Analysis' for function 'gcd9'
; DELIN-LABEL: gcd9
; DELIN: da analyze - output [* *]!
; DELIN: da analyze - flow [* *|<]!
; DELIN: da analyze - confused!

View File

@ -1,10 +1,11 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; 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 [* 0|<]!
; CHECK: da analyze - input [* *|<]!
; CHECK: da analyze - none!
define float @foo(float %g, [40 x float]* %rr) nounwind {

View File

@ -1,4 +1,3 @@
; RUN: opt < %s -analyze -basicaa -da -da-delinearize=false | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s -check-prefix=DELIN
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"
@ -13,15 +12,11 @@ target triple = "x86_64-apple-macosx10.6.0"
; other subscript. DependenceAnalysis before the fix crashed due to this
; mismatch.
define void @i32_subscript([100 x [100 x i32]]* %a, i32* %b) {
; CHECK-LABEL: 'Dependence Analysis' for function 'i32_subscript'
; DELIN-LABEL: 'Dependence Analysis' for function 'i32_subscript'
entry:
br label %for.body
for.body:
; CHECK: da analyze - none!
; CHECK: da analyze - anti [=|<]!
; CHECK: da analyze - none!
; DELIN: da analyze - none!
; DELIN: da analyze - anti [=|<]!
; DELIN: da analyze - none!
@ -55,16 +50,12 @@ target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define void @coupled_miv_type_mismatch(i32 %n) #0 {
; CHECK-LABEL: 'Dependence Analysis' for function 'coupled_miv_type_mismatch'
; DELIN-LABEL: 'Dependence Analysis' for function 'coupled_miv_type_mismatch'
entry:
br label %for.cond
; CHECK: da analyze - input [0 *]!
; CHECK: da analyze - anti [1 *]!
; CHECK: da analyze - none!
; DELIN: da analyze - input [0 *]!
; DELIN: da analyze - anti [1 *]!
; DELIN: da analyze - input [* *]!
; DELIN: da analyze - anti [* *|<]!
; DELIN: da analyze - none!
for.cond: ; preds = %for.inc11, %entry
%indvars.iv11 = phi i64 [ %indvars.iv.next12, %for.inc11 ], [ 1, %entry ]

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s
; ModuleID = 'Preliminary.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"
@ -13,6 +13,7 @@ define i32 @p0(i32 %n, i32* %A, i32* %B) nounwind uwtable ssp {
entry:
store i32 %n, i32* %A, align 4
; CHECK-LABEL: p0
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -31,6 +32,7 @@ define i32 @p1(i32 %n, i32* noalias %A, i32* noalias %B) nounwind uwtable ssp {
entry:
store i32 %n, i32* %A, align 4
; CHECK-LABEL: p1
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - none!
@ -54,10 +56,11 @@ entry:
%cmp10 = icmp sgt i64 %n, 0
br i1 %cmp10, label %for.cond1.preheader.preheader, label %for.end26
; CHECK: da analyze - none!
; CHECK: da analyze - flow [-3 -2]!
; CHECK-LABEL: p2
; CHECK: da analyze - output [* * *]!
; CHECK: da analyze - flow [* *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - input [* * *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - output [* * *]!
@ -142,6 +145,7 @@ for.end26: ; preds = %for.end26.loopexit,
}
; This ridiculous example is disabled: it does not make sense to keep it.
;; for (long int i = 0; i < n; i++)
;; for (long int j = 0; j < n; j++)
;; for (long int k = 0; k < n; k++)
@ -157,262 +161,262 @@ for.end26: ; preds = %for.end26.loopexit,
;; A[i - 3] [j] [2] [k-1] [2*l + 1] [m] [p + q] [r + s] = i;
;; *B++ = A[i + 3] [2] [u] [1-k] [3*l - 1] [o] [1 + n] [t + 2];
define void @p3(i64 %n, [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]]* %A, i64* %B) nounwind uwtable ssp {
entry:
%cmp44 = icmp sgt i64 %n, 0
br i1 %cmp44, label %for.cond1.preheader.preheader, label %for.end90
; CHECK: da analyze - output [0 0 0 0 0 S * * * * S S]!
; CHECK: da analyze - flow [-6 * * => * * * * * * * *] splitable!
; CHECK: da analyze - split level = 3, iteration = 1!
; CHECK: da analyze - confused!
; CHECK: da analyze - consistent input [0 S 0 0 S 0 S S S S 0 0]!
; CHECK: da analyze - confused!
; CHECK: da analyze - output [* * * * * * * * * * * *]!
for.cond1.preheader.preheader: ; preds = %entry
br label %for.cond1.preheader
for.cond1.preheader: ; preds = %for.cond1.preheader.preheader, %for.inc88
%B.addr.046 = phi i64* [ %B.addr.1.lcssa, %for.inc88 ], [ %B, %for.cond1.preheader.preheader ]
%i.045 = phi i64 [ %inc89, %for.inc88 ], [ 0, %for.cond1.preheader.preheader ]
%cmp240 = icmp sgt i64 %n, 0
br i1 %cmp240, label %for.cond4.preheader.preheader, label %for.inc88
for.cond4.preheader.preheader: ; preds = %for.cond1.preheader
br label %for.cond4.preheader
for.cond4.preheader: ; preds = %for.cond4.preheader.preheader, %for.inc85
%B.addr.142 = phi i64* [ %B.addr.2.lcssa, %for.inc85 ], [ %B.addr.046, %for.cond4.preheader.preheader ]
%j.041 = phi i64 [ %inc86, %for.inc85 ], [ 0, %for.cond4.preheader.preheader ]
%cmp536 = icmp sgt i64 %n, 0
br i1 %cmp536, label %for.cond7.preheader.preheader, label %for.inc85
for.cond7.preheader.preheader: ; preds = %for.cond4.preheader
br label %for.cond7.preheader
for.cond7.preheader: ; preds = %for.cond7.preheader.preheader, %for.inc82
%B.addr.238 = phi i64* [ %B.addr.3.lcssa, %for.inc82 ], [ %B.addr.142, %for.cond7.preheader.preheader ]
%k.037 = phi i64 [ %inc83, %for.inc82 ], [ 0, %for.cond7.preheader.preheader ]
%cmp832 = icmp sgt i64 %n, 0
br i1 %cmp832, label %for.cond10.preheader.preheader, label %for.inc82
for.cond10.preheader.preheader: ; preds = %for.cond7.preheader
br label %for.cond10.preheader
for.cond10.preheader: ; preds = %for.cond10.preheader.preheader, %for.inc79
%B.addr.334 = phi i64* [ %B.addr.4.lcssa, %for.inc79 ], [ %B.addr.238, %for.cond10.preheader.preheader ]
%l.033 = phi i64 [ %inc80, %for.inc79 ], [ 0, %for.cond10.preheader.preheader ]
%cmp1128 = icmp sgt i64 %n, 0
br i1 %cmp1128, label %for.cond13.preheader.preheader, label %for.inc79
for.cond13.preheader.preheader: ; preds = %for.cond10.preheader
br label %for.cond13.preheader
for.cond13.preheader: ; preds = %for.cond13.preheader.preheader, %for.inc76
%B.addr.430 = phi i64* [ %B.addr.5.lcssa, %for.inc76 ], [ %B.addr.334, %for.cond13.preheader.preheader ]
%m.029 = phi i64 [ %inc77, %for.inc76 ], [ 0, %for.cond13.preheader.preheader ]
%cmp1424 = icmp sgt i64 %n, 0
br i1 %cmp1424, label %for.cond16.preheader.preheader, label %for.inc76
for.cond16.preheader.preheader: ; preds = %for.cond13.preheader
br label %for.cond16.preheader
for.cond16.preheader: ; preds = %for.cond16.preheader.preheader, %for.inc73
%B.addr.526 = phi i64* [ %B.addr.6.lcssa, %for.inc73 ], [ %B.addr.430, %for.cond16.preheader.preheader ]
%o.025 = phi i64 [ %inc74, %for.inc73 ], [ 0, %for.cond16.preheader.preheader ]
%cmp1720 = icmp sgt i64 %n, 0
br i1 %cmp1720, label %for.cond19.preheader.preheader, label %for.inc73
for.cond19.preheader.preheader: ; preds = %for.cond16.preheader
br label %for.cond19.preheader
for.cond19.preheader: ; preds = %for.cond19.preheader.preheader, %for.inc70
%B.addr.622 = phi i64* [ %B.addr.7.lcssa, %for.inc70 ], [ %B.addr.526, %for.cond19.preheader.preheader ]
%p.021 = phi i64 [ %inc71, %for.inc70 ], [ 0, %for.cond19.preheader.preheader ]
%cmp2016 = icmp sgt i64 %n, 0
br i1 %cmp2016, label %for.cond22.preheader.preheader, label %for.inc70
for.cond22.preheader.preheader: ; preds = %for.cond19.preheader
br label %for.cond22.preheader
for.cond22.preheader: ; preds = %for.cond22.preheader.preheader, %for.inc67
%B.addr.718 = phi i64* [ %B.addr.8.lcssa, %for.inc67 ], [ %B.addr.622, %for.cond22.preheader.preheader ]
%q.017 = phi i64 [ %inc68, %for.inc67 ], [ 0, %for.cond22.preheader.preheader ]
%cmp2312 = icmp sgt i64 %n, 0
br i1 %cmp2312, label %for.cond25.preheader.preheader, label %for.inc67
for.cond25.preheader.preheader: ; preds = %for.cond22.preheader
br label %for.cond25.preheader
for.cond25.preheader: ; preds = %for.cond25.preheader.preheader, %for.inc64
%B.addr.814 = phi i64* [ %B.addr.9.lcssa, %for.inc64 ], [ %B.addr.718, %for.cond25.preheader.preheader ]
%r.013 = phi i64 [ %inc65, %for.inc64 ], [ 0, %for.cond25.preheader.preheader ]
%cmp268 = icmp sgt i64 %n, 0
br i1 %cmp268, label %for.cond28.preheader.preheader, label %for.inc64
for.cond28.preheader.preheader: ; preds = %for.cond25.preheader
br label %for.cond28.preheader
for.cond28.preheader: ; preds = %for.cond28.preheader.preheader, %for.inc61
%B.addr.910 = phi i64* [ %B.addr.10.lcssa, %for.inc61 ], [ %B.addr.814, %for.cond28.preheader.preheader ]
%s.09 = phi i64 [ %inc62, %for.inc61 ], [ 0, %for.cond28.preheader.preheader ]
%cmp294 = icmp sgt i64 %n, 0
br i1 %cmp294, label %for.cond31.preheader.preheader, label %for.inc61
for.cond31.preheader.preheader: ; preds = %for.cond28.preheader
br label %for.cond31.preheader
for.cond31.preheader: ; preds = %for.cond31.preheader.preheader, %for.inc58
%u.06 = phi i64 [ %inc59, %for.inc58 ], [ 0, %for.cond31.preheader.preheader ]
%B.addr.105 = phi i64* [ %B.addr.11.lcssa, %for.inc58 ], [ %B.addr.910, %for.cond31.preheader.preheader ]
%cmp321 = icmp sgt i64 %n, 0
br i1 %cmp321, label %for.body33.preheader, label %for.inc58
for.body33.preheader: ; preds = %for.cond31.preheader
br label %for.body33
for.body33: ; preds = %for.body33.preheader, %for.body33
%t.03 = phi i64 [ %inc, %for.body33 ], [ 0, %for.body33.preheader ]
%B.addr.112 = phi i64* [ %incdec.ptr, %for.body33 ], [ %B.addr.105, %for.body33.preheader ]
%add = add nsw i64 %r.013, %s.09
%add34 = add nsw i64 %p.021, %q.017
%mul = shl nsw i64 %l.033, 1
%add3547 = or i64 %mul, 1
%sub = add nsw i64 %k.037, -1
%sub36 = add nsw i64 %i.045, -3
%arrayidx43 = getelementptr inbounds [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]], [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]]* %A, i64 %sub36, i64 %j.041, i64 2, i64 %sub, i64 %add3547, i64 %m.029, i64 %add34, i64 %add
store i64 %i.045, i64* %arrayidx43, align 8
%add44 = add nsw i64 %t.03, 2
%add45 = add nsw i64 %n, 1
%mul46 = mul nsw i64 %l.033, 3
%sub47 = add nsw i64 %mul46, -1
%sub48 = sub nsw i64 1, %k.037
%add49 = add nsw i64 %i.045, 3
%arrayidx57 = getelementptr inbounds [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]], [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]]* %A, i64 %add49, i64 2, i64 %u.06, i64 %sub48, i64 %sub47, i64 %o.025, i64 %add45, i64 %add44
%0 = load i64, i64* %arrayidx57, align 8
%incdec.ptr = getelementptr inbounds i64, i64* %B.addr.112, i64 1
store i64 %0, i64* %B.addr.112, align 8
%inc = add nsw i64 %t.03, 1
%exitcond = icmp ne i64 %inc, %n
br i1 %exitcond, label %for.body33, label %for.inc58.loopexit
for.inc58.loopexit: ; preds = %for.body33
%scevgep = getelementptr i64, i64* %B.addr.105, i64 %n
br label %for.inc58
for.inc58: ; preds = %for.inc58.loopexit, %for.cond31.preheader
%B.addr.11.lcssa = phi i64* [ %B.addr.105, %for.cond31.preheader ], [ %scevgep, %for.inc58.loopexit ]
%inc59 = add nsw i64 %u.06, 1
%exitcond48 = icmp ne i64 %inc59, %n
br i1 %exitcond48, label %for.cond31.preheader, label %for.inc61.loopexit
for.inc61.loopexit: ; preds = %for.inc58
%B.addr.11.lcssa.lcssa = phi i64* [ %B.addr.11.lcssa, %for.inc58 ]
br label %for.inc61
for.inc61: ; preds = %for.inc61.loopexit, %for.cond28.preheader
%B.addr.10.lcssa = phi i64* [ %B.addr.910, %for.cond28.preheader ], [ %B.addr.11.lcssa.lcssa, %for.inc61.loopexit ]
%inc62 = add nsw i64 %s.09, 1
%exitcond49 = icmp ne i64 %inc62, %n
br i1 %exitcond49, label %for.cond28.preheader, label %for.inc64.loopexit
for.inc64.loopexit: ; preds = %for.inc61
%B.addr.10.lcssa.lcssa = phi i64* [ %B.addr.10.lcssa, %for.inc61 ]
br label %for.inc64
for.inc64: ; preds = %for.inc64.loopexit, %for.cond25.preheader
%B.addr.9.lcssa = phi i64* [ %B.addr.814, %for.cond25.preheader ], [ %B.addr.10.lcssa.lcssa, %for.inc64.loopexit ]
%inc65 = add nsw i64 %r.013, 1
%exitcond50 = icmp ne i64 %inc65, %n
br i1 %exitcond50, label %for.cond25.preheader, label %for.inc67.loopexit
for.inc67.loopexit: ; preds = %for.inc64
%B.addr.9.lcssa.lcssa = phi i64* [ %B.addr.9.lcssa, %for.inc64 ]
br label %for.inc67
for.inc67: ; preds = %for.inc67.loopexit, %for.cond22.preheader
%B.addr.8.lcssa = phi i64* [ %B.addr.718, %for.cond22.preheader ], [ %B.addr.9.lcssa.lcssa, %for.inc67.loopexit ]
%inc68 = add nsw i64 %q.017, 1
%exitcond51 = icmp ne i64 %inc68, %n
br i1 %exitcond51, label %for.cond22.preheader, label %for.inc70.loopexit
for.inc70.loopexit: ; preds = %for.inc67
%B.addr.8.lcssa.lcssa = phi i64* [ %B.addr.8.lcssa, %for.inc67 ]
br label %for.inc70
for.inc70: ; preds = %for.inc70.loopexit, %for.cond19.preheader
%B.addr.7.lcssa = phi i64* [ %B.addr.622, %for.cond19.preheader ], [ %B.addr.8.lcssa.lcssa, %for.inc70.loopexit ]
%inc71 = add nsw i64 %p.021, 1
%exitcond52 = icmp ne i64 %inc71, %n
br i1 %exitcond52, label %for.cond19.preheader, label %for.inc73.loopexit
for.inc73.loopexit: ; preds = %for.inc70
%B.addr.7.lcssa.lcssa = phi i64* [ %B.addr.7.lcssa, %for.inc70 ]
br label %for.inc73
for.inc73: ; preds = %for.inc73.loopexit, %for.cond16.preheader
%B.addr.6.lcssa = phi i64* [ %B.addr.526, %for.cond16.preheader ], [ %B.addr.7.lcssa.lcssa, %for.inc73.loopexit ]
%inc74 = add nsw i64 %o.025, 1
%exitcond53 = icmp ne i64 %inc74, %n
br i1 %exitcond53, label %for.cond16.preheader, label %for.inc76.loopexit
for.inc76.loopexit: ; preds = %for.inc73
%B.addr.6.lcssa.lcssa = phi i64* [ %B.addr.6.lcssa, %for.inc73 ]
br label %for.inc76
for.inc76: ; preds = %for.inc76.loopexit, %for.cond13.preheader
%B.addr.5.lcssa = phi i64* [ %B.addr.430, %for.cond13.preheader ], [ %B.addr.6.lcssa.lcssa, %for.inc76.loopexit ]
%inc77 = add nsw i64 %m.029, 1
%exitcond54 = icmp ne i64 %inc77, %n
br i1 %exitcond54, label %for.cond13.preheader, label %for.inc79.loopexit
for.inc79.loopexit: ; preds = %for.inc76
%B.addr.5.lcssa.lcssa = phi i64* [ %B.addr.5.lcssa, %for.inc76 ]
br label %for.inc79
for.inc79: ; preds = %for.inc79.loopexit, %for.cond10.preheader
%B.addr.4.lcssa = phi i64* [ %B.addr.334, %for.cond10.preheader ], [ %B.addr.5.lcssa.lcssa, %for.inc79.loopexit ]
%inc80 = add nsw i64 %l.033, 1
%exitcond55 = icmp ne i64 %inc80, %n
br i1 %exitcond55, label %for.cond10.preheader, label %for.inc82.loopexit
for.inc82.loopexit: ; preds = %for.inc79
%B.addr.4.lcssa.lcssa = phi i64* [ %B.addr.4.lcssa, %for.inc79 ]
br label %for.inc82
for.inc82: ; preds = %for.inc82.loopexit, %for.cond7.preheader
%B.addr.3.lcssa = phi i64* [ %B.addr.238, %for.cond7.preheader ], [ %B.addr.4.lcssa.lcssa, %for.inc82.loopexit ]
%inc83 = add nsw i64 %k.037, 1
%exitcond56 = icmp ne i64 %inc83, %n
br i1 %exitcond56, label %for.cond7.preheader, label %for.inc85.loopexit
for.inc85.loopexit: ; preds = %for.inc82
%B.addr.3.lcssa.lcssa = phi i64* [ %B.addr.3.lcssa, %for.inc82 ]
br label %for.inc85
for.inc85: ; preds = %for.inc85.loopexit, %for.cond4.preheader
%B.addr.2.lcssa = phi i64* [ %B.addr.142, %for.cond4.preheader ], [ %B.addr.3.lcssa.lcssa, %for.inc85.loopexit ]
%inc86 = add nsw i64 %j.041, 1
%exitcond57 = icmp ne i64 %inc86, %n
br i1 %exitcond57, label %for.cond4.preheader, label %for.inc88.loopexit
for.inc88.loopexit: ; preds = %for.inc85
%B.addr.2.lcssa.lcssa = phi i64* [ %B.addr.2.lcssa, %for.inc85 ]
br label %for.inc88
for.inc88: ; preds = %for.inc88.loopexit, %for.cond1.preheader
%B.addr.1.lcssa = phi i64* [ %B.addr.046, %for.cond1.preheader ], [ %B.addr.2.lcssa.lcssa, %for.inc88.loopexit ]
%inc89 = add nsw i64 %i.045, 1
%exitcond58 = icmp ne i64 %inc89, %n
br i1 %exitcond58, label %for.cond1.preheader, label %for.end90.loopexit
for.end90.loopexit: ; preds = %for.inc88
br label %for.end90
for.end90: ; preds = %for.end90.loopexit, %entry
ret void
}
;define void @p3(i64 %n, [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]]* %A, i64* %B) nounwind uwtable ssp {
;entry:
; %cmp44 = icmp sgt i64 %n, 0
; br i1 %cmp44, label %for.cond1.preheader.preheader, label %for.end90
;
;; DONT-CHECK-LABEL: p3
;; DONT-CHECK: da analyze - output [* * * * * S * * * * S S]!
;; DONT-CHECK: da analyze - flow [* * * * * * * * * * * *|<]!
;; DONT-CHECK: da analyze - confused!
;; DONT-CHECK: da analyze - input [* S * * S * S S S S * *]!
;; DONT-CHECK: da analyze - confused!
;; DONT-CHECK: da analyze - output [* * * * * * * * * * * *]!
;
;for.cond1.preheader.preheader: ; preds = %entry
; br label %for.cond1.preheader
;
;for.cond1.preheader: ; preds = %for.cond1.preheader.preheader, %for.inc88
; %B.addr.046 = phi i64* [ %B.addr.1.lcssa, %for.inc88 ], [ %B, %for.cond1.preheader.preheader ]
; %i.045 = phi i64 [ %inc89, %for.inc88 ], [ 0, %for.cond1.preheader.preheader ]
; %cmp240 = icmp sgt i64 %n, 0
; br i1 %cmp240, label %for.cond4.preheader.preheader, label %for.inc88
;
;for.cond4.preheader.preheader: ; preds = %for.cond1.preheader
; br label %for.cond4.preheader
;
;for.cond4.preheader: ; preds = %for.cond4.preheader.preheader, %for.inc85
; %B.addr.142 = phi i64* [ %B.addr.2.lcssa, %for.inc85 ], [ %B.addr.046, %for.cond4.preheader.preheader ]
; %j.041 = phi i64 [ %inc86, %for.inc85 ], [ 0, %for.cond4.preheader.preheader ]
; %cmp536 = icmp sgt i64 %n, 0
; br i1 %cmp536, label %for.cond7.preheader.preheader, label %for.inc85
;
;for.cond7.preheader.preheader: ; preds = %for.cond4.preheader
; br label %for.cond7.preheader
;
;for.cond7.preheader: ; preds = %for.cond7.preheader.preheader, %for.inc82
; %B.addr.238 = phi i64* [ %B.addr.3.lcssa, %for.inc82 ], [ %B.addr.142, %for.cond7.preheader.preheader ]
; %k.037 = phi i64 [ %inc83, %for.inc82 ], [ 0, %for.cond7.preheader.preheader ]
; %cmp832 = icmp sgt i64 %n, 0
; br i1 %cmp832, label %for.cond10.preheader.preheader, label %for.inc82
;
;for.cond10.preheader.preheader: ; preds = %for.cond7.preheader
; br label %for.cond10.preheader
;
;for.cond10.preheader: ; preds = %for.cond10.preheader.preheader, %for.inc79
; %B.addr.334 = phi i64* [ %B.addr.4.lcssa, %for.inc79 ], [ %B.addr.238, %for.cond10.preheader.preheader ]
; %l.033 = phi i64 [ %inc80, %for.inc79 ], [ 0, %for.cond10.preheader.preheader ]
; %cmp1128 = icmp sgt i64 %n, 0
; br i1 %cmp1128, label %for.cond13.preheader.preheader, label %for.inc79
;
;for.cond13.preheader.preheader: ; preds = %for.cond10.preheader
; br label %for.cond13.preheader
;
;for.cond13.preheader: ; preds = %for.cond13.preheader.preheader, %for.inc76
; %B.addr.430 = phi i64* [ %B.addr.5.lcssa, %for.inc76 ], [ %B.addr.334, %for.cond13.preheader.preheader ]
; %m.029 = phi i64 [ %inc77, %for.inc76 ], [ 0, %for.cond13.preheader.preheader ]
; %cmp1424 = icmp sgt i64 %n, 0
; br i1 %cmp1424, label %for.cond16.preheader.preheader, label %for.inc76
;
;for.cond16.preheader.preheader: ; preds = %for.cond13.preheader
; br label %for.cond16.preheader
;
;for.cond16.preheader: ; preds = %for.cond16.preheader.preheader, %for.inc73
; %B.addr.526 = phi i64* [ %B.addr.6.lcssa, %for.inc73 ], [ %B.addr.430, %for.cond16.preheader.preheader ]
; %o.025 = phi i64 [ %inc74, %for.inc73 ], [ 0, %for.cond16.preheader.preheader ]
; %cmp1720 = icmp sgt i64 %n, 0
; br i1 %cmp1720, label %for.cond19.preheader.preheader, label %for.inc73
;
;for.cond19.preheader.preheader: ; preds = %for.cond16.preheader
; br label %for.cond19.preheader
;
;for.cond19.preheader: ; preds = %for.cond19.preheader.preheader, %for.inc70
; %B.addr.622 = phi i64* [ %B.addr.7.lcssa, %for.inc70 ], [ %B.addr.526, %for.cond19.preheader.preheader ]
; %p.021 = phi i64 [ %inc71, %for.inc70 ], [ 0, %for.cond19.preheader.preheader ]
; %cmp2016 = icmp sgt i64 %n, 0
; br i1 %cmp2016, label %for.cond22.preheader.preheader, label %for.inc70
;
;for.cond22.preheader.preheader: ; preds = %for.cond19.preheader
; br label %for.cond22.preheader
;
;for.cond22.preheader: ; preds = %for.cond22.preheader.preheader, %for.inc67
; %B.addr.718 = phi i64* [ %B.addr.8.lcssa, %for.inc67 ], [ %B.addr.622, %for.cond22.preheader.preheader ]
; %q.017 = phi i64 [ %inc68, %for.inc67 ], [ 0, %for.cond22.preheader.preheader ]
; %cmp2312 = icmp sgt i64 %n, 0
; br i1 %cmp2312, label %for.cond25.preheader.preheader, label %for.inc67
;
;for.cond25.preheader.preheader: ; preds = %for.cond22.preheader
; br label %for.cond25.preheader
;
;for.cond25.preheader: ; preds = %for.cond25.preheader.preheader, %for.inc64
; %B.addr.814 = phi i64* [ %B.addr.9.lcssa, %for.inc64 ], [ %B.addr.718, %for.cond25.preheader.preheader ]
; %r.013 = phi i64 [ %inc65, %for.inc64 ], [ 0, %for.cond25.preheader.preheader ]
; %cmp268 = icmp sgt i64 %n, 0
; br i1 %cmp268, label %for.cond28.preheader.preheader, label %for.inc64
;
;for.cond28.preheader.preheader: ; preds = %for.cond25.preheader
; br label %for.cond28.preheader
;
;for.cond28.preheader: ; preds = %for.cond28.preheader.preheader, %for.inc61
; %B.addr.910 = phi i64* [ %B.addr.10.lcssa, %for.inc61 ], [ %B.addr.814, %for.cond28.preheader.preheader ]
; %s.09 = phi i64 [ %inc62, %for.inc61 ], [ 0, %for.cond28.preheader.preheader ]
; %cmp294 = icmp sgt i64 %n, 0
; br i1 %cmp294, label %for.cond31.preheader.preheader, label %for.inc61
;
;for.cond31.preheader.preheader: ; preds = %for.cond28.preheader
; br label %for.cond31.preheader
;
;for.cond31.preheader: ; preds = %for.cond31.preheader.preheader, %for.inc58
; %u.06 = phi i64 [ %inc59, %for.inc58 ], [ 0, %for.cond31.preheader.preheader ]
; %B.addr.105 = phi i64* [ %B.addr.11.lcssa, %for.inc58 ], [ %B.addr.910, %for.cond31.preheader.preheader ]
; %cmp321 = icmp sgt i64 %n, 0
; br i1 %cmp321, label %for.body33.preheader, label %for.inc58
;
;for.body33.preheader: ; preds = %for.cond31.preheader
; br label %for.body33
;
;for.body33: ; preds = %for.body33.preheader, %for.body33
; %t.03 = phi i64 [ %inc, %for.body33 ], [ 0, %for.body33.preheader ]
; %B.addr.112 = phi i64* [ %incdec.ptr, %for.body33 ], [ %B.addr.105, %for.body33.preheader ]
; %add = add nsw i64 %r.013, %s.09
; %add34 = add nsw i64 %p.021, %q.017
; %mul = shl nsw i64 %l.033, 1
; %add3547 = or i64 %mul, 1
; %sub = add nsw i64 %k.037, -1
; %sub36 = add nsw i64 %i.045, -3
; %arrayidx43 = getelementptr inbounds [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]], [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]]* %A, i64 %sub36, i64 %j.041, i64 2, i64 %sub, i64 %add3547, i64 %m.029, i64 %add34, i64 %add
; store i64 %i.045, i64* %arrayidx43, align 8
; %add44 = add nsw i64 %t.03, 2
; %add45 = add nsw i64 %n, 1
; %mul46 = mul nsw i64 %l.033, 3
; %sub47 = add nsw i64 %mul46, -1
; %sub48 = sub nsw i64 1, %k.037
; %add49 = add nsw i64 %i.045, 3
; %arrayidx57 = getelementptr inbounds [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]], [100 x [100 x [100 x [100 x [100 x [100 x [100 x i64]]]]]]]* %A, i64 %add49, i64 2, i64 %u.06, i64 %sub48, i64 %sub47, i64 %o.025, i64 %add45, i64 %add44
; %0 = load i64, i64* %arrayidx57, align 8
; %incdec.ptr = getelementptr inbounds i64, i64* %B.addr.112, i64 1
; store i64 %0, i64* %B.addr.112, align 8
; %inc = add nsw i64 %t.03, 1
; %exitcond = icmp ne i64 %inc, %n
; br i1 %exitcond, label %for.body33, label %for.inc58.loopexit
;
;for.inc58.loopexit: ; preds = %for.body33
; %scevgep = getelementptr i64, i64* %B.addr.105, i64 %n
; br label %for.inc58
;
;for.inc58: ; preds = %for.inc58.loopexit, %for.cond31.preheader
; %B.addr.11.lcssa = phi i64* [ %B.addr.105, %for.cond31.preheader ], [ %scevgep, %for.inc58.loopexit ]
; %inc59 = add nsw i64 %u.06, 1
; %exitcond48 = icmp ne i64 %inc59, %n
; br i1 %exitcond48, label %for.cond31.preheader, label %for.inc61.loopexit
;
;for.inc61.loopexit: ; preds = %for.inc58
; %B.addr.11.lcssa.lcssa = phi i64* [ %B.addr.11.lcssa, %for.inc58 ]
; br label %for.inc61
;
;for.inc61: ; preds = %for.inc61.loopexit, %for.cond28.preheader
; %B.addr.10.lcssa = phi i64* [ %B.addr.910, %for.cond28.preheader ], [ %B.addr.11.lcssa.lcssa, %for.inc61.loopexit ]
; %inc62 = add nsw i64 %s.09, 1
; %exitcond49 = icmp ne i64 %inc62, %n
; br i1 %exitcond49, label %for.cond28.preheader, label %for.inc64.loopexit
;
;for.inc64.loopexit: ; preds = %for.inc61
; %B.addr.10.lcssa.lcssa = phi i64* [ %B.addr.10.lcssa, %for.inc61 ]
; br label %for.inc64
;
;for.inc64: ; preds = %for.inc64.loopexit, %for.cond25.preheader
; %B.addr.9.lcssa = phi i64* [ %B.addr.814, %for.cond25.preheader ], [ %B.addr.10.lcssa.lcssa, %for.inc64.loopexit ]
; %inc65 = add nsw i64 %r.013, 1
; %exitcond50 = icmp ne i64 %inc65, %n
; br i1 %exitcond50, label %for.cond25.preheader, label %for.inc67.loopexit
;
;for.inc67.loopexit: ; preds = %for.inc64
; %B.addr.9.lcssa.lcssa = phi i64* [ %B.addr.9.lcssa, %for.inc64 ]
; br label %for.inc67
;
;for.inc67: ; preds = %for.inc67.loopexit, %for.cond22.preheader
; %B.addr.8.lcssa = phi i64* [ %B.addr.718, %for.cond22.preheader ], [ %B.addr.9.lcssa.lcssa, %for.inc67.loopexit ]
; %inc68 = add nsw i64 %q.017, 1
; %exitcond51 = icmp ne i64 %inc68, %n
; br i1 %exitcond51, label %for.cond22.preheader, label %for.inc70.loopexit
;
;for.inc70.loopexit: ; preds = %for.inc67
; %B.addr.8.lcssa.lcssa = phi i64* [ %B.addr.8.lcssa, %for.inc67 ]
; br label %for.inc70
;
;for.inc70: ; preds = %for.inc70.loopexit, %for.cond19.preheader
; %B.addr.7.lcssa = phi i64* [ %B.addr.622, %for.cond19.preheader ], [ %B.addr.8.lcssa.lcssa, %for.inc70.loopexit ]
; %inc71 = add nsw i64 %p.021, 1
; %exitcond52 = icmp ne i64 %inc71, %n
; br i1 %exitcond52, label %for.cond19.preheader, label %for.inc73.loopexit
;
;for.inc73.loopexit: ; preds = %for.inc70
; %B.addr.7.lcssa.lcssa = phi i64* [ %B.addr.7.lcssa, %for.inc70 ]
; br label %for.inc73
;
;for.inc73: ; preds = %for.inc73.loopexit, %for.cond16.preheader
; %B.addr.6.lcssa = phi i64* [ %B.addr.526, %for.cond16.preheader ], [ %B.addr.7.lcssa.lcssa, %for.inc73.loopexit ]
; %inc74 = add nsw i64 %o.025, 1
; %exitcond53 = icmp ne i64 %inc74, %n
; br i1 %exitcond53, label %for.cond16.preheader, label %for.inc76.loopexit
;
;for.inc76.loopexit: ; preds = %for.inc73
; %B.addr.6.lcssa.lcssa = phi i64* [ %B.addr.6.lcssa, %for.inc73 ]
; br label %for.inc76
;
;for.inc76: ; preds = %for.inc76.loopexit, %for.cond13.preheader
; %B.addr.5.lcssa = phi i64* [ %B.addr.430, %for.cond13.preheader ], [ %B.addr.6.lcssa.lcssa, %for.inc76.loopexit ]
; %inc77 = add nsw i64 %m.029, 1
; %exitcond54 = icmp ne i64 %inc77, %n
; br i1 %exitcond54, label %for.cond13.preheader, label %for.inc79.loopexit
;
;for.inc79.loopexit: ; preds = %for.inc76
; %B.addr.5.lcssa.lcssa = phi i64* [ %B.addr.5.lcssa, %for.inc76 ]
; br label %for.inc79
;
;for.inc79: ; preds = %for.inc79.loopexit, %for.cond10.preheader
; %B.addr.4.lcssa = phi i64* [ %B.addr.334, %for.cond10.preheader ], [ %B.addr.5.lcssa.lcssa, %for.inc79.loopexit ]
; %inc80 = add nsw i64 %l.033, 1
; %exitcond55 = icmp ne i64 %inc80, %n
; br i1 %exitcond55, label %for.cond10.preheader, label %for.inc82.loopexit
;
;for.inc82.loopexit: ; preds = %for.inc79
; %B.addr.4.lcssa.lcssa = phi i64* [ %B.addr.4.lcssa, %for.inc79 ]
; br label %for.inc82
;
;for.inc82: ; preds = %for.inc82.loopexit, %for.cond7.preheader
; %B.addr.3.lcssa = phi i64* [ %B.addr.238, %for.cond7.preheader ], [ %B.addr.4.lcssa.lcssa, %for.inc82.loopexit ]
; %inc83 = add nsw i64 %k.037, 1
; %exitcond56 = icmp ne i64 %inc83, %n
; br i1 %exitcond56, label %for.cond7.preheader, label %for.inc85.loopexit
;
;for.inc85.loopexit: ; preds = %for.inc82
; %B.addr.3.lcssa.lcssa = phi i64* [ %B.addr.3.lcssa, %for.inc82 ]
; br label %for.inc85
;
;for.inc85: ; preds = %for.inc85.loopexit, %for.cond4.preheader
; %B.addr.2.lcssa = phi i64* [ %B.addr.142, %for.cond4.preheader ], [ %B.addr.3.lcssa.lcssa, %for.inc85.loopexit ]
; %inc86 = add nsw i64 %j.041, 1
; %exitcond57 = icmp ne i64 %inc86, %n
; br i1 %exitcond57, label %for.cond4.preheader, label %for.inc88.loopexit
;
;for.inc88.loopexit: ; preds = %for.inc85
; %B.addr.2.lcssa.lcssa = phi i64* [ %B.addr.2.lcssa, %for.inc85 ]
; br label %for.inc88
;
;for.inc88: ; preds = %for.inc88.loopexit, %for.cond1.preheader
; %B.addr.1.lcssa = phi i64* [ %B.addr.046, %for.cond1.preheader ], [ %B.addr.2.lcssa.lcssa, %for.inc88.loopexit ]
; %inc89 = add nsw i64 %i.045, 1
; %exitcond58 = icmp ne i64 %inc89, %n
; br i1 %exitcond58, label %for.cond1.preheader, label %for.end90.loopexit
;
;for.end90.loopexit: ; preds = %for.inc88
; br label %for.end90
;
;for.end90: ; preds = %for.end90.loopexit, %entry
; ret void
;}
;;void p4(int *A, int *B, long int n) {
@ -425,10 +429,11 @@ entry:
%cmp1 = icmp sgt i64 %n, 0
br i1 %cmp1, label %for.body.preheader, label %for.end
; CHECK-LABEL: p4
; CHECK: da analyze - output [*]!
; CHECK: da analyze - flow [*|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - input [*]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -471,10 +476,11 @@ entry:
%cmp1 = icmp sgt i64 %n, 0
br i1 %cmp1, label %for.body.preheader, label %for.end
; CHECK-LABEL: p5
; CHECK: da analyze - output [*]!
; CHECK: da analyze - flow [*|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - input [*]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -517,6 +523,7 @@ entry:
%cmp1 = icmp sgt i64 %n, 0
br i1 %cmp1, label %for.body.preheader, label %for.end
; CHECK-LABEL: p6
; CHECK: da analyze - none!
; CHECK: da analyze - consistent flow [2]!
; CHECK: da analyze - confused!
@ -559,6 +566,7 @@ entry:
%idxprom = sext i8 %n to i64
%arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
; CHECK-LABEL: p7
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -586,6 +594,7 @@ entry:
%arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
store i32 0, i32* %arrayidx, align 4
; CHECK-LABEL: p8
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -612,8 +621,9 @@ entry:
%arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
store i32 0, i32* %arrayidx, align 4
; CHECK-LABEL: p9
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - flow [|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -638,8 +648,9 @@ entry:
%arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
store i32 0, i32* %arrayidx, align 4
; CHECK-LABEL: p10
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - flow [|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -664,7 +675,7 @@ entry:
%struct.S = type { i32 }
define void @f(%struct.S* %s, i32 %size) nounwind uwtable ssp {
define void @foo(%struct.S* %s, i32 %size) nounwind uwtable ssp {
entry:
%idx.ext = zext i32 %size to i64
%add.ptr.sum = add i64 %idx.ext, -1
@ -672,6 +683,7 @@ entry:
%cmp1 = icmp eq i64 %add.ptr.sum, 0
br i1 %cmp1, label %while.end, label %while.body.preheader
; CHECK-LABEL: foo
; CHECK: da analyze - none!
; CHECK: da analyze - consistent anti [1]!
; CHECK: da analyze - none!

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s
; ModuleID = 'Propagating.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"
@ -14,8 +14,9 @@ define void @prop0([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop0
; CHECK: da analyze - none!
; CHECK: da analyze - consistent flow [1 -1]!
; CHECK: da analyze - flow [< >]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -64,10 +65,11 @@ define void @prop1([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable ss
entry:
br label %for.cond1.preheader
; CHECK: da analyze - none!
; CHECK: da analyze - consistent flow [1 1 -1]!
; CHECK-LABEL: prop1
; CHECK: da analyze - output [* * *]!
; CHECK: da analyze - flow [<> <> *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - input [* * *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -126,8 +128,9 @@ define void @prop2([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop2
; CHECK: da analyze - consistent output [0 S]!
; CHECK: da analyze - none!
; CHECK: da analyze - flow [> *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -176,10 +179,11 @@ define void @prop3([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK-LABEL: prop3
; CHECK: da analyze - output [* *]!
; CHECK: da analyze - flow [<> *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - input [* *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -227,8 +231,9 @@ define void @prop4([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop4
; CHECK: da analyze - none!
; CHECK: da analyze - consistent flow [2 -3]!
; CHECK: da analyze - flow [< <>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -279,9 +284,9 @@ define void @prop5([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable ss
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop5
; CHECK: da analyze - none!
; CHECK: da analyze - flow [< -16] splitable!
; CHECK: da analyze - split level = 1, iteration = 11!
; CHECK: da analyze - flow [* *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -333,8 +338,9 @@ define void @prop6([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop6
; CHECK: da analyze - none!
; CHECK: da analyze - flow [=> -2]!
; CHECK: da analyze - flow [=> <>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -386,9 +392,9 @@ define void @prop7([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop7
; CHECK: da analyze - none!
; CHECK: da analyze - flow [* -38] splitable!
; CHECK: da analyze - split level = 1, iteration = 4!
; CHECK: da analyze - flow [* <>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -442,8 +448,9 @@ define void @prop8([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop8
; CHECK: da analyze - consistent output [S 0]!
; CHECK: da analyze - flow [p<= 2]!
; CHECK: da analyze - flow [=> <]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -493,8 +500,9 @@ define void @prop9([100 x i32]* %A, i32* %B, i32 %n) nounwind uwtable ssp {
entry:
br label %for.cond1.preheader
; CHECK-LABEL: prop9
; CHECK: da analyze - none!
; CHECK: da analyze - flow [p<= 2]!
; CHECK: da analyze - flow [<= <]!
; CHECK: da analyze - confused!
; CHECK: da analyze - consistent input [S 0]!
; CHECK: da analyze - confused!

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | 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"
@ -16,10 +16,10 @@ define void @sep0([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable ssp
entry:
br label %for.cond1.preheader
; CHECK: da analyze - output [0 * * S]!
; CHECK: da analyze - flow [-10 * * *]!
; CHECK: da analyze - output [= * * S]!
; CHECK: da analyze - flow [* * * *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [0 * S *]!
; CHECK: da analyze - input [* * S *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -91,10 +91,10 @@ define void @sep1([100 x [100 x i32]]* %A, i32* %B, i32 %n) nounwind uwtable ssp
entry:
br label %for.cond1.preheader
; CHECK: da analyze - output [0 * * S]!
; CHECK: da analyze - flow [> * * *]!
; CHECK: da analyze - output [= * * S]!
; CHECK: da analyze - flow [* * * *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [0 * S *]!
; CHECK: da analyze - input [* * S *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -165,10 +165,10 @@ define void @sep2([100 x [100 x [100 x i32]]]* %A, i32* %B, i32 %n) nounwind uwt
entry:
br label %for.cond1.preheader
; CHECK: da analyze - consistent output [0 S 0 0]!
; CHECK: da analyze - flow [> * * -10]!
; CHECK: da analyze - output [= S = =]!
; CHECK: da analyze - flow [* * * <>]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [0 * * 0]!
; CHECK: da analyze - input [= * * *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
@ -239,10 +239,10 @@ define void @sep3([100 x [100 x [100 x i32]]]* %A, i32* %B, i32 %n) nounwind uwt
entry:
br label %for.cond1.preheader
; CHECK: da analyze - consistent output [0 S 0 0]!
; CHECK: da analyze - flow [> * * *]!
; CHECK: da analyze - output [= S = =]!
; CHECK: da analyze - flow [* * * *|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - input [0 * * 0]!
; CHECK: da analyze - input [= * * *]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s
; ModuleID = 'StrongSIV.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"
@ -328,7 +328,7 @@ entry:
br label %for.body
; CHECK: da analyze - none!
; CHECK: da analyze - consistent flow [%n|<]!
; CHECK: da analyze - flow [*|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!

View File

@ -1,4 +1,4 @@
; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
; RUN: opt < %s -analyze -basicaa -da -da-delinearize | FileCheck %s
; ModuleID = 'SymbolicSIV.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"
@ -291,7 +291,7 @@ entry:
; CHECK: da analyze - none!
; CHECK: da analyze - flow [*|<] splitable!
; CHECK: da analyze - split level = 1, iteration = ((0 smax (-1 + (-1 * %n))) /u 2)!
; CHECK: da analyze - split level = 1, iteration = ((0 smax (-4 + (-4 * %n))) /u 8)!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -334,8 +334,9 @@ entry:
%cmp1 = icmp eq i64 %n, 0
br i1 %cmp1, label %for.end, label %for.body.preheader
; CHECK-LABEL: symbolicsiv6
; CHECK: da analyze - none!
; CHECK: da analyze - none!
; CHECK: da analyze - flow [0|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!
@ -382,9 +383,9 @@ define void @symbolicsiv7(i32* %A, i32* %B, i64 %n, i64 %N, i64 %M) nounwind uwt
entry:
%cmp1 = icmp eq i64 %n, 0
br i1 %cmp1, label %for.end, label %for.body.preheader
; CHECK-LABEL: symbolicsiv7
; CHECK: da analyze - none!
; CHECK: da analyze - flow [<>]!
; CHECK: da analyze - flow [0|<]!
; CHECK: da analyze - confused!
; CHECK: da analyze - none!
; CHECK: da analyze - confused!

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -20,6 +20,8 @@ declare void @bar(i64 %a) readnone
;; }
;; }
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_01(i32 %k, i32 %N) {
entry:
%cmp21 = icmp sgt i32 %N, 0
@ -65,24 +67,6 @@ exit:
ret void
}
; CHECK-LABEL: @interchange_01
; CHECK: for1.ph:
; CHECK: br label %for1.header
; CHECK: for1.header:
; CHECK-NEXT: %indvars.iv23 = phi i64 [ 0, %for1.ph ], [ %indvars.iv.next24, %for1.inc10 ]
; CHECK-NEXT: br i1 %cmp219, label %for2.ph, label %for1.inc10
; CHECK: for2:
; CHECK: br i1 %exitcond, label %for2.loopexit, label %for2
; CHECK: for1.inc10:
; CHECK: br i1 %exitcond26, label %for1.loopexit, label %for1.header
; CHECK: for1.loopexit:
; CHECK-NEXT: br label %exit
;;--------------------------------------Test case 02------------------------------------
;; Safe to interchange, because the called function `bar` is marked as readnone,
;; so it cannot introduce dependences.
@ -94,6 +78,8 @@ exit:
;; }
;; }
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_02(i32 %k, i32 %N) {
entry:
%cmp21 = icmp sgt i32 %N, 0
@ -138,21 +124,3 @@ for1.loopexit:
exit:
ret void
}
; CHECK-LABEL: @interchange_02
; CHECK: for1.header:
; CHECK-NEXT: %indvars.iv23 = phi i64 [ 0, %for1.ph ], [ %indvars.iv.next24, %for1.inc10 ]
; CHECK-NEXT: br i1 %cmp219, label %for2.split1, label %for1.loopexit
; CHECK: for2.split1:
; CHECK: br label %for2.loopexit
; CHECK: for2.split:
; CHECK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: br i1 %exitcond, label %for1.loopexit, label %for2
; CHECK: for2.loopexit:
; CHECK-NEXT: br label %for1.inc10
; CHECK: for1.inc10:
; CHECK: br i1 %exitcond26, label %for2.split, label %for1.header

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -13,6 +13,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(gj=1;gj<M;gj++)
;; A[gj][gi] = A[gj - 1][gi] + C[gj][gi];
; CHECK: PHI Nodes in loop nest exit is not handled for now since on failure all loops branch to loop nest exit.
@gi = common global i32 0
@gj = common global i32 0
@ -66,11 +68,3 @@ for.cond.for.end16_crit_edge:
for.end16:
ret void
}
; CHECK-LABEL: @interchange_07
; CHECK: for.body3: ; preds = %for.body3.preheader, %for.body3
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3 ], [ 1, %for.body3.preheader ]
; CHECK: %5 = add nsw i64 %indvars.iv, -1
; CHECK: %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %5, i64 %indvars.iv25
; CHECK: %6 = load i32, i32* %arrayidx5
; CHECK: %arrayidx9 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @C, i64 0, i64 %indvars.iv, i64 %indvars.iv25

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
;; These are test that fail to interchange due to current limitation. This will go off once we extend the loop interchange pass.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -14,6 +14,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int j=1;j<N-1;j++)
;; A[j+1][i+1] = A[j+1][i+1] + k;
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_01(i32 %k, i32 %N) {
entry:
%sub = add nsw i32 %N, -1
@ -49,10 +51,3 @@ define void @interchange_01(i32 %k, i32 %N) {
for.end17:
ret void
}
;; Inner loop not split so it is not interchanged.
; CHECK-LABEL: @interchange_01
; CHECK: for.body4:
; CHECK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 1, %for.body4.preheader ]
; CHECK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK-NEXT: %arrayidx7 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv.next, i64 %indvars.iv.next29

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -20,6 +20,12 @@ target triple = "x86_64-unknown-linux-gnu"
;; fn2(T[k]);
;; }
; CHECK: Processing Inner Loop Id = 2 and OuterLoopId = 1
; CHECK: Loops interchanged.
; CHECK: Processing Inner Loop Id = 1 and OuterLoopId = 0
; CHECK: Not interchanging loops. Cannot prove legality.
@T = internal global [100 x double] zeroinitializer, align 4
@Arr = internal global [1000 x [1000 x i32]] zeroinitializer, align 4
@ -67,52 +73,3 @@ for.body9: ; preds = %for.body9, %for.con
declare double @fn1() readnone
declare void @fn2(double) readnone
;; After interchange %indvars.iv (j) should increment as the middle loop.
;; After interchange %indvars.iv42 (i) should increment with the inner most loop.
; CHECK-LABEL: @interchange_09
; CHECK: for.body:
; CHECK: %indvars.iv45 = phi i64 [ %indvars.iv.next46, %for.cond.cleanup4 ], [ 0, %for.body.preheader ]
; CHECK: %call = call double @fn1()
; CHECK: %arrayidx = getelementptr inbounds [100 x double], [100 x double]* @T, i64 0, i64 %indvars.iv45
; CHECK: store double %call, double* %arrayidx, align 8
; CHECK: br label %for.body9.preheader
; CHECK: for.cond6.preheader.preheader:
; CHECK: br label %for.cond6.preheader
; CHECK: for.cond6.preheader:
; CHECK: %indvars.iv42 = phi i64 [ %indvars.iv.next43, %for.cond.cleanup8 ], [ 0, %for.cond6.preheader.preheader ]
; CHECK: br label %for.body9.split1
; CHECK: for.body9.preheader:
; CHECK: br label %for.body9
; CHECK: for.cond.cleanup4:
; CHECK: %tmp = load double, double* %arrayidx, align 8
; CHECK: call void @fn2(double %tmp)
; CHECK: %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
; CHECK: %exitcond47 = icmp ne i64 %indvars.iv.next46, 100
; CHECK: br i1 %exitcond47, label %for.body, label %for.cond.cleanup
; CHECK: for.cond.cleanup8:
; CHECK: %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
; CHECK: %exitcond44 = icmp ne i64 %indvars.iv.next43, 1000
; CHECK: br i1 %exitcond44, label %for.cond6.preheader, label %for.body9.split
; CHECK: for.body9:
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body9.split ], [ 1, %for.body9.preheader ]
; CHECK: br label %for.cond6.preheader.preheader
; CHECK: for.body9.split1:
; CHECK: %arrayidx13 = getelementptr inbounds [1000 x [1000 x i32]], [1000 x [1000 x i32]]* @Arr, i64 0, i64 %indvars.iv, i64 %indvars.iv42
; CHECK: store i32 %add, i32* %arrayidx13, align 4
; CHECK: br label %for.cond.cleanup8
; CHECK: for.body9.split:
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: %exitcond = icmp ne i64 %indvars.iv.next, 1000
; CHECK: br i1 %exitcond, label %for.body9, label %for.cond.cleanup4

View File

@ -1,8 +1,8 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
; RUN: opt < %s -basicaa -da-delinearize -loop-interchange -verify-dom-info -S -pass-remarks=loop-interchange 2>&1 | FileCheck %s
@A10 = local_unnamed_addr global [3 x [3 x i32]] zeroinitializer, align 16
;; Test to make sure we can handle zext intructions introduced by
;; Test to make sure we can handle zext instructions introduced by
;; IndVarSimplify.
;;
;; for (int i = 0; i < 2; ++i)
@ -10,6 +10,8 @@
;; A[j][i] = i;
;; }
; CHECK: Loop interchanged with enclosing loop.
@A11 = local_unnamed_addr global [3 x [3 x i32]] zeroinitializer, align 16
define void @interchange_11(i32 %n) {
@ -30,9 +32,11 @@ for.cond.cleanup: ; preds = %for.cond.loopexit
for.body4: ; preds = %for.body4, %for.cond1.preheader
%indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.body4 ]
%arrayidx6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv26
%tmp = trunc i64 %indvars.iv26 to i32
store i32 %tmp, i32* %arrayidx6, align 4
; The store below does not appear in the C snippet above.
; With two stores in the loop there may be WAW dependences, and interchange is illegal.
; %arrayidx6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv26
; %tmp = trunc i64 %indvars.iv26 to i32
; store i32 %tmp, i32* %arrayidx6, align 4
%arrayidx10 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv.next27
%tmp1 = trunc i64 %indvars.iv to i32
store i32 %tmp1, i32* %arrayidx10, align 4
@ -41,40 +45,3 @@ for.body4: ; preds = %for.body4, %for.con
%exitcond = icmp ne i64 %indvars.iv.next, %n.wide
br i1 %exitcond, label %for.body4, label %for.cond.loopexit
}
; CHECK-LABEL: @interchange_11
; CHECK: entry:
; CHECK: br label %for.body4.preheader
; CHECK: for.cond1.preheader.preheader:
; CHECK: br label %for.cond1.preheader
; CHECK: for.cond.loopexit:
; CHECK: %exitcond28 = icmp ne i64 %indvars.iv.next27, 2
; CHECK: br i1 %exitcond28, label %for.cond1.preheader, label %for.body4.split
; CHECK: for.cond1.preheader:
; CHECK: %indvars.iv26 = phi i64 [ %indvars.iv.next27, %for.cond.loopexit ], [ 0, %for.cond1.preheader.preheader ]
; CHECK: %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
; CHECK: br label %for.body4.split1
; CHECK: for.body4.preheader:
; CHECK: br label %for.body4
; CHECK: for.cond.cleanup:
; CHECK: ret void
; CHECK: for.body4:
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4.split ], [ 0, %for.body4.preheader ]
; CHECK: br label %for.cond1.preheader.preheader
; CHECK: for.body4.split1:
; CHECK: %arrayidx6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv26
; CHECK: %tmp = trunc i64 %indvars.iv26 to i32
; CHECK: store i32 %tmp, i32* %arrayidx6, align 4
; CHECK: br label %for.cond.loopexit
; CHECK: for.body4.split:
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: %exitcond = icmp ne i64 %indvars.iv.next, %n.wide
; CHECK: br i1 %exitcond, label %for.body4, label %for.cond.cleanup

View File

@ -1,40 +0,0 @@
; RUN: opt < %s -loop-interchange -S | FileCheck %s
; BB latch1 is the loop latch, but does not exit the loop.
define void @foo() {
entry:
%dest = alloca i16*, align 8
br label %header1
header1:
%0 = phi i16* [ %2, %latch1 ], [ undef, %entry ]
br i1 false, label %inner, label %loopexit
inner:
br i1 undef, label %inner.ph, label %latch1
inner.ph:
br label %inner.body
inner.body:
%1 = load i16, i16* %0, align 2
store i16* inttoptr (i64 2 to i16*), i16** %dest, align 8
br i1 false, label %inner.body, label %inner.loopexit
inner.loopexit:
br label %latch1
latch1:
%2 = phi i16* [ %0, %inner ], [ undef, %inner.loopexit ]
br label %header1
loopexit: ; preds = %header1
unreachable
}
; CHECK-LABEL: inner.body:
; CHECK: br i1 false, label %inner.body, label %inner.loopexit
; CHECK: latch1:
; CHECK-NEXT: %2 = phi i16* [ %0, %inner ], [ undef, %inner.loopexit ]
; CHECK-NEXT: br label %header1

View File

@ -1,6 +1,8 @@
; RUN: opt < %s -loop-interchange -simplifycfg -S | FileCheck %s
; RUN: opt < %s -loop-interchange -simplifycfg -S -pass-remarks=loop-interchange 2>&1 | FileCheck %s
; CHECK: Loop interchanged with enclosing loop.
; no_deps_interchange just access a single nested array and can be interchange.
define i32 @no_deps_interchange([1024 x i32]* nocapture %Arr, i32 %k) local_unnamed_addr #0 {
entry:
br label %for.body
@ -26,19 +28,3 @@ for.cond.cleanup3: ; preds = %for.body4
for.cond.cleanup: ; preds = %for.cond.cleanup3
ret i32 0
}
; CHECK-LABEL: @no_deps_interchange
; CHECK-LABEL: entry:
; CHECK-NEXT: br label %for.body4
; CHECK-LABEL: for.body: ; preds = %for.body4, %for.body
; CHECK: %indvars.iv19 = phi i64 [ %indvars.iv.next20, %for.body ], [ 0, %for.body4 ]
; CHECK: br i1 %exitcond21, label %for.body, label %for.body4.split
; CHECK-LABEL: for.body4: ; preds = %entry, %for.body4.split
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4.split ], [ 0, %entry ]
; CHECK: br label %for.body
; CHECK-LABEL: for.body4.split: ; preds = %for.body
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: br i1 %exitcond, label %for.body4, label %for.cond.cleanup

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -12,6 +12,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int j=0;j<100;j++)
;; A[i][j] = A[i][j]+k;
; CHECK: Interchanging loops not profitable.
define void @interchange_03(i32 %k) {
entry:
br label %for.cond1.preheader
@ -38,29 +40,3 @@ for.inc10:
for.end12:
ret void
}
; CHECK-LABEL: @interchange_03
; CHECK: entry:
; CHECK: br label %for.cond1.preheader.preheader
; CHECK: for.cond1.preheader.preheader: ; preds = %entry
; CHECK: br label %for.cond1.preheader
; CHECK: for.cond1.preheader: ; preds = %for.cond1.preheader.preheader, %for.inc10
; CHECK: %indvars.iv21 = phi i64 [ %indvars.iv.next22, %for.inc10 ], [ 0, %for.cond1.preheader.preheader ]
; CHECK: br label %for.body3.preheader
; CHECK: for.body3.preheader: ; preds = %for.cond1.preheader
; CHECK: br label %for.body3
; CHECK: for.body3: ; preds = %for.body3.preheader, %for.body3
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3 ], [ 0, %for.body3.preheader ]
; CHECK: %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv21, i64 %indvars.iv
; CHECK: %0 = load i32, i32* %arrayidx5
; CHECK: %add = add nsw i32 %0, %k
; CHECK: store i32 %add, i32* %arrayidx5
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: %exitcond = icmp eq i64 %indvars.iv.next, 100
; CHECK: br i1 %exitcond, label %for.inc10, label %for.body3
; CHECK: for.inc10: ; preds = %for.body3
; CHECK: %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
; CHECK: %exitcond23 = icmp eq i64 %indvars.iv.next22, 100
; CHECK: br i1 %exitcond23, label %for.end12, label %for.cond1.preheader
; CHECK: for.end12: ; preds = %for.inc10
; CHECK: ret void

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -14,6 +14,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; A[j][i+1] = j;
;; }
; CHECK: Not interchanging loops. Cannot prove legality.
@A10 = local_unnamed_addr global [3 x [3 x i32]] zeroinitializer, align 16
define void @interchange_10() {
@ -44,43 +46,3 @@ for.body4: ; preds = %for.body4, %for.con
%exitcond = icmp ne i64 %indvars.iv.next, 3
br i1 %exitcond, label %for.body4, label %for.cond.loopexit
}
; CHECK-LABEL: @interchange_10
; CHECK: entry:
; CHECK: br label %for.body4.preheader
; CHECK: for.cond1.preheader.preheader:
; CHECK: br label %for.cond1.preheader
; CHECK: for.cond.loopexit:
; CHECK: %exitcond28 = icmp ne i64 %indvars.iv.next27, 2
; CHECK: br i1 %exitcond28, label %for.cond1.preheader, label %for.body4.split
; CHECK: for.cond1.preheader:
; CHECK: %indvars.iv26 = phi i64 [ %indvars.iv.next27, %for.cond.loopexit ], [ 0, %for.cond1.preheader.preheader ]
; CHECK: %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
; CHECK: br label %for.body4.split1
; CHECK: for.body4.preheader:
; CHECK: br label %for.body4
; CHECK: for.cond.cleanup:
; CHECK: ret void
; CHECK: for.body4:
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4.split ], [ 0, %for.body4.preheader ]
; CHECK: br label %for.cond1.preheader.preheader
; CHECK: for.body4.split1:
; CHECK: %arrayidx6 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv26
; CHECK: %tmp = trunc i64 %indvars.iv26 to i32
; CHECK: store i32 %tmp, i32* %arrayidx6, align 4
; CHECK: %arrayidx10 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* @A10, i64 0, i64 %indvars.iv, i64 %indvars.iv.next27
; CHECK: %tmp1 = trunc i64 %indvars.iv to i32
; CHECK: store i32 %tmp1, i32* %arrayidx10, align 4
; CHECK: br label %for.cond.loopexit
; CHECK: for.body4.split:
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: %exitcond = icmp ne i64 %indvars.iv.next, 3
; CHECK: br i1 %exitcond, label %for.body4, label %for.cond.cleanup

View File

@ -1,5 +1,4 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -pass-remarks=loop-interchange 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -11,6 +10,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int j=100;j>=0;j--)
;; A[j][i] = A[j][i]+k;
; CHECK: Loop interchanged with enclosing loop.
define void @interchange_02(i32 %k) {
entry:
br label %for.cond1.preheader
@ -37,33 +38,3 @@ for.inc10:
for.end11:
ret void
}
; CHECK-LABEL: @interchange_02
; CHECK: entry:
; CHECK: br label %for.body3.preheader
; CHECK: for.cond1.preheader.preheader:
; CHECK: br label %for.cond1.preheader
; CHECK: for.cond1.preheader:
; CHECK: %indvars.iv19 = phi i64 [ %indvars.iv.next20, %for.inc10 ], [ 0, %for.cond1.preheader.preheader ]
; CHECK: br label %for.body3.split1
; CHECK: for.body3.preheader:
; CHECK: br label %for.body3
; CHECK: for.body3:
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.split ], [ 100, %for.body3.preheader ]
; CHECK: br label %for.cond1.preheader.preheader
; CHECK: for.body3.split1: ; preds = %for.cond1.preheader
; CHECK: %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv, i64 %indvars.iv19
; CHECK: %0 = load i32, i32* %arrayidx5
; CHECK: %add = add nsw i32 %0, %k
; CHECK: store i32 %add, i32* %arrayidx5
; CHECK: br label %for.inc10
; CHECK: for.body3.split:
; CHECK: %indvars.iv.next = add nsw i64 %indvars.iv, -1
; CHECK: %cmp2 = icmp sgt i64 %indvars.iv, 0
; CHECK: br i1 %cmp2, label %for.body3, label %for.end11
; CHECK: for.inc10:
; CHECK: %indvars.iv.next20 = add nuw nsw i64 %indvars.iv19, 1
; CHECK: %exitcond = icmp eq i64 %indvars.iv.next20, 100
; CHECK: br i1 %exitcond, label %for.body3.split, label %for.cond1.preheader
; CHECK: for.end11:
; CHECK: ret void

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -11,6 +11,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int j=1;j<N;j++)
;; A[j][i] = A[j][i]+k;
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_01(i32 %k, i32 %N) {
entry:
%cmp21 = icmp sgt i32 %N, 0
@ -45,42 +47,3 @@ for.inc10:
for.end12:
ret void
}
; CHECK-LABEL: @interchange_01
; CHECK: entry:
; CHECK: %cmp21 = icmp sgt i32 %N, 0
; CHECK: br i1 %cmp21, label %for.body3.preheader, label %for.end12
; CHECK: for.cond1.preheader.lr.ph:
; CHECK: br label %for.cond1.preheader
; CHECK: for.cond1.preheader:
; CHECK: %indvars.iv23 = phi i64 [ 0, %for.cond1.preheader.lr.ph ], [ %indvars.iv.next24, %for.inc10 ]
; CHECK: br i1 %cmp219, label %for.body3.split1, label %for.end12.loopexit
; CHECK: for.body3.preheader:
; CHECK: %cmp219 = icmp sgt i32 %N, 1
; CHECK: %0 = add i32 %N, -1
; CHECK: br label %for.body3
; CHECK: for.body3:
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.split ], [ 1, %for.body3.preheader ]
; CHECK: br label %for.cond1.preheader.lr.ph
; CHECK: for.body3.split1:
; CHECK: %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv, i64 %indvars.iv23
; CHECK: %1 = load i32, i32* %arrayidx5
; CHECK: %add = add nsw i32 %1, %k
; CHECK: store i32 %add, i32* %arrayidx5
; CHECK: br label %for.inc10.loopexit
; CHECK: for.body3.split:
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: %lftr.wideiv = trunc i64 %indvars.iv to i32
; CHECK: %exitcond = icmp eq i32 %lftr.wideiv, %0
; CHECK: br i1 %exitcond, label %for.end12.loopexit, label %for.body3
; CHECK: for.inc10.loopexit:
; CHECK: br label %for.inc10
; CHECK: for.inc10:
; CHECK: %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
; CHECK: %lftr.wideiv25 = trunc i64 %indvars.iv23 to i32
; CHECK: %exitcond26 = icmp eq i32 %lftr.wideiv25, %0
; CHECK: br i1 %exitcond26, label %for.body3.split, label %for.cond1.preheader
; CHECK: for.end12.loopexit:
; CHECK: br label %for.end12
; CHECK: for.end12:
; CHECK: ret void

View File

@ -54,14 +54,10 @@ for.end19:
; CHECK: --- !Missed
; CHECK-NEXT: Pass: loop-interchange
; CHECK-NEXT: Name: InterchangeNotProfitable
; CHECK-NEXT: Name: Dependence
; CHECK-NEXT: Function: test01
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: 'Interchanging loops is too costly (cost='
; CHECK-NEXT: - Cost: '2'
; CHECK-NEXT: - String: ', threshold='
; CHECK-NEXT: - Threshold: '0'
; CHECK-NEXT: - String: ') and it does not improve parallelism.'
; CHECK-NEXT: - String: Cannot interchange loops due to dependences.
; CHECK-NEXT: ...
;;--------------------------------------Test case 02------------------------------------
@ -110,10 +106,10 @@ define void @test02(i32 %k, i32 %N) {
; CHECK: --- !Missed
; CHECK-NEXT: Pass: loop-interchange
; CHECK-NEXT: Name: UnsupportedInsBetweenInduction
; CHECK-NEXT: Name: Dependence
; CHECK-NEXT: Function: test02
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: Found unsupported instruction between induction variable increment and branch.
; CHECK-NEXT: - String: Cannot interchange loops due to dependences.
; CHECK-NEXT: ...
;;-----------------------------------Test case 03-------------------------------
@ -156,12 +152,12 @@ for.body4: ; preds = %for.body4, %for.con
br i1 %exitcond, label %for.body4, label %for.cond.loopexit
}
; CHECK: --- !Passed
; CHECK: --- !Missed
; CHECK-NEXT: Pass: loop-interchange
; CHECK-NEXT: Name: Interchanged
; CHECK-NEXT: Name: Dependence
; CHECK-NEXT: Function: test03
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: Loop interchanged with enclosing loop.
; CHECK-NEXT: - String: Cannot interchange loops due to dependences.
; CHECK-NEXT: ...
;;--------------------------------------Test case 04-------------------------------------
@ -213,8 +209,8 @@ for.end17:
; CHECK: --- !Missed
; CHECK-NEXT: Pass: loop-interchange
; CHECK-NEXT: Name: NotTightlyNested
; CHECK-NEXT: Name: Dependence
; CHECK-NEXT: Function: test04
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: Cannot interchange loops because they are not tightly nested.
; CHECK-NEXT: - String: Cannot interchange loops due to dependences.
; CHECK-NEXT: ...

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -12,6 +12,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int i=0;i<99;i++)
;; A[j][i+1] = A[j+1][i]+k;
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_04(i32 %k){
entry:
br label %for.cond1.preheader
@ -39,26 +41,3 @@ for.inc12:
for.end14:
ret void
}
; CHECK-LABEL: @interchange_04
; CHECK: entry:
; CHECK: br label %for.cond1.preheader
; CHECK: for.cond1.preheader: ; preds = %for.inc12, %entry
; CHECK: %indvars.iv23 = phi i64 [ 0, %entry ], [ %indvars.iv.next24, %for.inc12 ]
; CHECK: %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
; CHECK: br label %for.body3
; CHECK: for.body3: ; preds = %for.body3, %for.cond1.preheader
; CHECK: %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.body3 ]
; CHECK: %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv.next24, i64 %indvars.iv
; CHECK: %0 = load i32, i32* %arrayidx5
; CHECK: %add6 = add nsw i32 %0, %k
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: %arrayidx11 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv23, i64 %indvars.iv.next
; CHECK: store i32 %add6, i32* %arrayidx11
; CHECK: %exitcond = icmp eq i64 %indvars.iv.next, 99
; CHECK: br i1 %exitcond, label %for.inc12, label %for.body3
; CHECK: for.inc12: ; preds = %for.body3
; CHECK: %exitcond25 = icmp eq i64 %indvars.iv.next24, 99
; CHECK: br i1 %exitcond25, label %for.end14, label %for.cond1.preheader
; CHECK: for.end14: ; preds = %for.inc12
; CHECK: ret void

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -12,6 +12,12 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int k=0;k<100;k++)
;; D[i][k][j] = D[i][k][j]+t;
; CHECK: Processing Inner Loop Id = 2 and OuterLoopId = 1
; CHECK: Loops interchanged.
; CHECK: Processing Inner Loop Id = 1 and OuterLoopId = 0
; CHECK: Interchanging loops not profitable.
define void @interchange_08(i32 %t){
entry:
br label %for.cond1.preheader
@ -47,41 +53,3 @@ for.inc15: ; preds = %for.inc12
for.end17: ; preds = %for.inc15
ret void
}
; CHECK-LABEL: @interchange_08
; CHECK: entry:
; CHECK: br label %for.cond1.preheader.preheader
; CHECK: for.cond1.preheader.preheader: ; preds = %entry
; CHECK: br label %for.cond1.preheader
; CHECK: for.cond1.preheader: ; preds = %for.cond1.preheader.preheader, %for.inc15
; CHECK: %i.028 = phi i32 [ %inc16, %for.inc15 ], [ 0, %for.cond1.preheader.preheader ]
; CHECK: br label %for.body6.preheader
; CHECK: for.cond4.preheader.preheader: ; preds = %for.body6
; CHECK: br label %for.cond4.preheader
; CHECK: for.cond4.preheader: ; preds = %for.cond4.preheader.preheader, %for.inc12
; CHECK: %j.027 = phi i32 [ %inc13, %for.inc12 ], [ 0, %for.cond4.preheader.preheader ]
; CHECK: br label %for.body6.split1
; CHECK: for.body6.preheader: ; preds = %for.cond1.preheader
; CHECK: br label %for.body6
; CHECK: for.body6: ; preds = %for.body6.preheader, %for.body6.split
; CHECK: %k.026 = phi i32 [ %inc, %for.body6.split ], [ 0, %for.body6.preheader ]
; CHECK: br label %for.cond4.preheader.preheader
; CHECK: for.body6.split1: ; preds = %for.cond4.preheader
; CHECK: %arrayidx8 = getelementptr inbounds [100 x [100 x [100 x i32]]], [100 x [100 x [100 x i32]]]* @D, i32 0, i32 %i.028, i32 %k.026, i32 %j.027
; CHECK: %0 = load i32, i32* %arrayidx8
; CHECK: %add = add nsw i32 %0, %t
; CHECK: store i32 %add, i32* %arrayidx8
; CHECK: br label %for.inc12
; CHECK: for.body6.split: ; preds = %for.inc12
; CHECK: %inc = add nuw nsw i32 %k.026, 1
; CHECK: %exitcond = icmp eq i32 %inc, 100
; CHECK: br i1 %exitcond, label %for.inc15, label %for.body6
; CHECK: for.inc12: ; preds = %for.body6.split1
; CHECK: %inc13 = add nuw nsw i32 %j.027, 1
; CHECK: %exitcond29 = icmp eq i32 %inc13, 100
; CHECK: br i1 %exitcond29, label %for.body6.split, label %for.cond4.preheader
; CHECK: for.inc15: ; preds = %for.body6.split
; CHECK: %inc16 = add nuw nsw i32 %i.028, 1
; CHECK: %exitcond30 = icmp eq i32 %inc16, 100
; CHECK: br i1 %exitcond30, label %for.end17, label %for.cond1.preheader
; CHECK: for.end17: ; preds = %for.inc15
; CHECK: ret void

View File

@ -1,5 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -S | FileCheck %s
;; We test the complete .ll for adjustment in outer loop header/latch and inner loop header/latch.
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -S -debug 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@ -16,6 +16,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; A[j][i] = A[j][i]+B[j];
;; }
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_05(i32 %k, i32 %N){
entry:
%cmp30 = icmp sgt i32 %N, 0
@ -55,44 +57,6 @@ for.end17:
ret void
}
; CHECK-LABEL: @interchange_05
; CHECK: entry:
; CHECK: %cmp30 = icmp sgt i32 %N, 0
; CHECK: br i1 %cmp30, label %for.body.lr.ph, label %for.end17
; CHECK: for.body.lr.ph:
; CHECK: %0 = add i32 %N, -1
; CHECK: %1 = zext i32 %k to i64
; CHECK: br label %for.body
; CHECK: for.body:
; CHECK: %indvars.iv32 = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next33, %for.inc15 ]
; CHECK: %2 = add nsw i64 %indvars.iv32, %1
; CHECK: %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* @B, i64 0, i64 %indvars.iv32
; CHECK: %3 = trunc i64 %2 to i32
; CHECK: store i32 %3, i32* %arrayidx
; CHECK: br label %for.body3.preheader
; CHECK: for.body3.preheader:
; CHECK: br label %for.body3
; CHECK: for.body3:
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3 ], [ 0, %for.body3.preheader ]
; CHECK: %arrayidx7 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv32, i64 %indvars.iv
; CHECK: %4 = load i32, i32* %arrayidx7
; CHECK: %add10 = add nsw i32 %3, %4
; CHECK: store i32 %add10, i32* %arrayidx7
; CHECK: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
; CHECK: %lftr.wideiv = trunc i64 %indvars.iv to i32
; CHECK: %exitcond = icmp eq i32 %lftr.wideiv, %0
; CHECK: br i1 %exitcond, label %for.inc15, label %for.body3
; CHECK: for.inc15:
; CHECK: %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1
; CHECK: %lftr.wideiv35 = trunc i64 %indvars.iv32 to i32
; CHECK: %exitcond36 = icmp eq i32 %lftr.wideiv35, %0
; CHECK: br i1 %exitcond36, label %for.end17.loopexit, label %for.body
; CHECK: for.end17.loopexit:
; CHECK: br label %for.end17
; CHECK: for.end17:
; CHECK: ret void
declare void @foo(...) readnone
;; Loops not tightly nested are not interchanged
@ -102,6 +66,8 @@ declare void @foo(...) readnone
;; A[j][i] = A[j][i]+k;
;; }
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_06(i32 %k, i32 %N) {
entry:
%cmp22 = icmp sgt i32 %N, 0
@ -136,8 +102,3 @@ for.inc10:
for.end12:
ret void
}
;; Here we are checking if the inner phi is not split then we have not interchanged.
; CHECK-LABEL: @interchange_06
; CHECK: phi i64 [ %indvars.iv.next, %for.body3 ], [ 2, %for.body3.preheader ]
; CHECK-NEXT: getelementptr
; CHECK-NEXT: %1 = load

View File

@ -1,7 +1,10 @@
; RUN: opt < %s -loop-interchange -verify-dom-info -S | FileCheck %s
; REQUIRES: asserts
; RUN: opt < %s -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
;; Checks the order of the inner phi nodes does not cause havoc.
;; The inner loop has a reduction into c. The IV is not the first phi.
; CHECK: Not interchanging loops. Cannot prove legality.
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv8--linux-gnueabihf"
@ -61,30 +64,3 @@ for.end21.loopexit: ; preds = %for.inc19
for.end21: ; preds = %for.end21.loopexit, %entry
ret void
}
; CHECK-LABEL: test
; CHECK: entry:
; CHECK: br i1 %cmp45, label %for.body6.preheader, label %for.end21
; CHECK: for.body3.lr.ph.preheader:
; CHECK: br label %for.body3.lr.ph
; CHECK: for.body3.lr.ph:
; CHECK: br label %for.body6.lr.ph.preheader
; CHECK: for.body6.lr.ph.preheader:
; CHECK: br label %for.body6.lr.ph
; CHECK: for.body6.lr.ph:
; CHECK: br label %for.body6.split1
; CHECK: for.body6.preheader:
; CHECK: br label %for.body6
; CHECK: for.body6:
; CHECK: br label %for.body3.lr.ph.preheader
; CHECK: for.body6.split1:
; CHECK: br label %for.inc16
; CHECK: for.body6.split:
; CHECK: add nuw nsw i32 %k.040, 1
; CHECK: br i1 %exitcond, label %for.end21.loopexit, label %for.body6
; CHECK: for.inc16:
; CHECK: br i1 %exitcond47, label %for.inc19, label %for.body6.lr.ph
; CHECK: for.inc19:
; CHECK: br i1 %exitcond48, label %for.body6.split, label %for.body3.lr.ph
; CHECK: for.end21:

View File

@ -1,4 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
;; We test profitability model in these test cases.
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@ -13,6 +14,8 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int j=1;j<N;j++)
;; A[j][i] = A[j - 1][i] + B[j][i];
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_01(i32 %N) {
entry:
%cmp27 = icmp sgt i32 %N, 1
@ -50,30 +53,6 @@ for.inc14:
for.end16:
ret void
}
;; Here we are checking partial .ll to check if loop are interchanged.
; CHECK-LABEL: @interchange_01
; CHECK: for.body3.preheader: ; preds = %for.inc14, %for.cond1.preheader.lr.ph
; CHECK: %indvars.iv30 = phi i64 [ 1, %for.cond1.preheader.lr.ph ], [ %indvars.iv.next31, %for.inc14 ]
; CHECK: br label %for.body3.split2
; CHECK: for.body3.preheader1: ; preds = %entry
; CHECK: br label %for.body3
; CHECK: for.body3: ; preds = %for.body3.preheader1, %for.body3.split
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.split ], [ 1, %for.body3.preheader1 ]
; CHECK: br label %for.cond1.preheader.lr.ph
; CHECK: for.body3.split2: ; preds = %for.body3.preheader
; CHECK: %1 = add nsw i64 %indvars.iv, -1
; CHECK: %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %1, i64 %indvars.iv30
; CHECK: %2 = load i32, i32* %arrayidx5
; CHECK: %arrayidx9 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @B, i64 0, i64 %indvars.iv, i64 %indvars.iv30
; CHECK: %3 = load i32, i32* %arrayidx9
; CHECK: %add = add nsw i32 %3, %2
; CHECK: %arrayidx13 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv, i64 %indvars.iv30
; CHECK: store i32 %add, i32* %arrayidx13
; CHECK: br label %for.inc14
;; ---------------------------------------Test case 02---------------------------------
;; Check loop interchange profitability model.
@ -83,6 +62,8 @@ for.end16:
;; for(int j=1;j<N;j++)
;; A[j-1][i-1] = A[j - 1][i-1] + B[j-1][i-1];
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_02(i32 %N) {
entry:
%cmp32 = icmp sgt i32 %N, 1
@ -120,30 +101,6 @@ for.inc19:
for.end21:
ret void
}
; CHECK-LABEL: @interchange_02
; CHECK: for.body3.lr.ph: ; preds = %for.inc19, %for.cond1.preheader.lr.ph
; CHECK: %indvars.iv35 = phi i64 [ 1, %for.cond1.preheader.lr.ph ], [ %indvars.iv.next36, %for.inc19 ]
; CHECK: %0 = add nsw i64 %indvars.iv35, -1
; CHECK: br label %for.body3.split1
; CHECK: for.body3.preheader: ; preds = %entry
; CHECK: %1 = add i32 %N, -1
; CHECK: br label %for.body3
; CHECK: for.body3: ; preds = %for.body3.preheader, %for.body3.split
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.split ], [ 1, %for.body3.preheader ]
; CHECK: br label %for.cond1.preheader.lr.ph
; CHECK: for.body3.split1: ; preds = %for.body3.lr.ph
; CHECK: %2 = add nsw i64 %indvars.iv, -1
; CHECK: %arrayidx6 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %2, i64 %0
; CHECK: %3 = load i32, i32* %arrayidx6
; CHECK: %arrayidx12 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @B, i64 0, i64 %2, i64 %0
; CHECK: %4 = load i32, i32* %arrayidx12
; CHECK: %add = add nsw i32 %4, %3
; CHECK: store i32 %add, i32* %arrayidx6
; CHECK: br label %for.inc19
;;---------------------------------------Test case 03---------------------------------
;; Loops interchange is not profitable.
@ -151,6 +108,8 @@ for.end21:
;; for(int j=1;j<N;j++)
;; A[i-1][j-1] = A[i - 1][j-1] + B[i][j];
; CHECK: Not interchanging loops. Cannot prove legality.
define void @interchange_03(i32 %N){
entry:
%cmp31 = icmp sgt i32 %N, 1
@ -188,18 +147,3 @@ for.inc17:
for.end19:
ret void
}
; CHECK-LABEL: @interchange_03
; CHECK: for.body3.lr.ph:
; CHECK: %indvars.iv34 = phi i64 [ 1, %for.cond1.preheader.lr.ph ], [ %indvars.iv.next35, %for.inc17 ]
; CHECK: %1 = add nsw i64 %indvars.iv34, -1
; CHECK: br label %for.body3.preheader
; CHECK: for.body3.preheader:
; CHECK: br label %for.body3
; CHECK: for.body3:
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3 ], [ 1, %for.body3.preheader ]
; CHECK: %2 = add nsw i64 %indvars.iv, -1
; CHECK: %arrayidx6 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %1, i64 %2
; CHECK: %3 = load i32, i32* %arrayidx6
; CHECK: %arrayidx10 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @B, i64 0, i64 %indvars.iv34, i64 %indvars.iv
; CHECK: %4 = load i32, i32* %arrayidx10

View File

@ -1,4 +1,5 @@
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S | FileCheck %s
; REQUIRES: asserts
; RUN: opt < %s -basicaa -loop-interchange -verify-dom-info -S -debug 2>&1 | FileCheck %s
@A = common global [500 x [500 x i32]] zeroinitializer
@X = common global i32 0
@ -9,6 +10,9 @@
;; for( int j=1;j<N;j++)
;; X+=A[j][i];
;; Loop is interchanged check that the phi nodes are split and the promoted value is used instead of the reduction phi.
; CHECK: Loops interchanged.
define void @reduction_01(i32 %N) {
entry:
%cmp16 = icmp sgt i32 %N, 1
@ -41,14 +45,6 @@ for.end8: ; preds = %for.cond1.for.inc6_
ret void
}
;; Loop is interchanged check that the phi nodes are split and the promoted value is used instead of the reduction phi.
; CHECK-LABEL: @reduction_01
; CHECK: for.body3: ; preds = %for.body3.preheader, %for.body3.split
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body3.split ], [ 1, %for.body3.preheader ]
; CHECK: br label %for.body3.lr.ph.preheader
; CHECK: %add = add nsw i32 %X.promoted
;; Test for more than 1 reductions inside a loop.
;; for( int i=1;i<N;i++)
;; for( int j=1;j<N;j++)
@ -57,6 +53,9 @@ for.end8: ; preds = %for.cond1.for.inc6_
;; Y+=B[k][i];
;; }
;; Loop is interchanged check that the phi nodes are split and the promoted value is used instead of the reduction phi.
; CHECK: Loops interchanged.
define void @reduction_02(i32 %N) {
entry:
%cmp34 = icmp sgt i32 %N, 1
@ -105,14 +104,6 @@ for.end19: ; preds = %for.inc17, %entry
ret void
}
;; Loop is interchanged check that the phi nodes are split and the promoted value is used instead of the reduction phi.
; CHECK-LABEL: @reduction_02
; CHECK: for.body6: ; preds = %for.body6.preheader, %for.body6.split
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body6.split ], [ 1, %for.body6.preheader ]
; CHECK: br label %for.cond4.preheader.preheader.preheader
; CHECK: %add13 = add nsw i32 %Y.promoted
;; Not tightly nested. Do not interchange.
;; for( int i=1;i<N;i++)
;; for( int j=1;j<N;j++) {
@ -121,6 +112,11 @@ for.end19: ; preds = %for.inc17, %entry
;; }
;; Y+=B[j][i];
;; }
;; Not tightly nested. Do not interchange.
;; Not interchanged hence the phi's in the inner loop will not be split. Check for the same.
; CHECK: Not interchanging loops. Cannot prove legality.
define void @reduction_03(i32 %N) {
entry:
%cmp35 = icmp sgt i32 %N, 1
@ -168,14 +164,6 @@ for.cond1.for.inc17_crit_edge: ; preds = %for.cond4.for.end_c
for.end19: ; preds = %for.cond1.for.inc17_crit_edge, %entry
ret void
}
;; Not tightly nested. Do not interchange.
;; Not interchanged hence the phi's in the inner loop will not be split. Check for the same.
; CHECK-LABEL: @reduction_03
; CHECK: for.body6: ; preds = %for.body6.preheader, %for.body6
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body6 ], [ 1, %for.body6.preheader ]
; CHECK: %add31 = phi i32 [ %add, %for.body6 ], [ %X.promoted, %for.body6.preheader ]
;; Multiple use of reduction not safe. Do not interchange.
;; for( int i=1;i<N;i++)
@ -184,6 +172,10 @@ for.end19: ; preds = %for.cond1.for.inc17
;; X+=A[k][j];
;; Y+=X;
;; }
;; Not interchanged hence the phi's in the inner loop will not be split. Check for the same.
; CHECK: Not interchanging loops. Cannot prove legality.
define void @reduction_04(i32 %N) {
entry:
%cmp28 = icmp sgt i32 %N, 1
@ -228,8 +220,3 @@ for.inc13: ; preds = %for.cond4.for.inc10
for.end15: ; preds = %for.inc13, %entry
ret void
}
;; Not interchanged hence the phi's in the inner loop will not be split. Check for the same.
; CHECK-LABEL: @reduction_04
; CHECK: for.body6: ; preds = %for.body6.preheader, %for.body6
; CHECK: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body6 ], [ 1, %for.body6.preheader ]
; CHECK: %add925 = phi i32 [ %add9, %for.body6 ], [ %Y.promoted, %for.body6.preheader ]