llvm.org GIT mirror llvm / 3073329
Use WriteAsOperand instead of getName() to print loop header names, so that unnamed blocks are handled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93059 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
22 changed file(s) with 48 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
127127 if (!AddRecStride->properlyDominates(Header, DT))
128128 return false;
129129
130 DEBUG(dbgs() << "[" << L->getHeader()->getName()
131 << "] Variable stride: " << *AddRec << "\n");
130 DEBUG(dbgs() << "[";
131 WriteAsOperand(dbgs(), L->getHeader(), /*PrintType=*/false);
132 dbgs() << "] Variable stride: " << *AddRec << "\n");
132133 }
133134
134135 Stride = AddRecStride;
315315 OS << "{" << *Operands[0];
316316 for (unsigned i = 1, e = Operands.size(); i != e; ++i)
317317 OS << ",+," << *Operands[i];
318 OS << "}<" << L->getHeader()->getName() + ">";
318 OS << "}<";
319 WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false);
320 OS << ">";
319321 }
320322
321323 void SCEVFieldOffsetExpr::print(raw_ostream &OS) const {
51925194 for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
51935195 PrintLoopInfo(OS, SE, *I);
51945196
5195 OS << "Loop " << L->getHeader()->getName() << ": ";
5197 OS << "Loop ";
5198 WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false);
5199 OS << ": ";
51965200
51975201 SmallVector ExitBlocks;
51985202 L->getExitBlocks(ExitBlocks);
52055209 OS << "Unpredictable backedge-taken count. ";
52065210 }
52075211
5208 OS << "\n";
5209 OS << "Loop " << L->getHeader()->getName() << ": ";
5212 OS << "\n"
5213 "Loop ";
5214 WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false);
5215 OS << ": ";
52105216
52115217 if (!isa(SE->getMaxBackedgeTakenCount(L))) {
52125218 OS << "max backedge-taken count is " << *SE->getMaxBackedgeTakenCount(L);
52265232 // const isn't dangerous.
52275233 ScalarEvolution &SE = *const_cast(this);
52285234
5229 OS << "Classifying expressions for: " << F->getName() << "\n";
5235 OS << "Classifying expressions for: ";
5236 WriteAsOperand(OS, F, /*PrintType=*/false);
5237 OS << "\n";
52305238 for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
52315239 if (isSCEVable(I->getType())) {
52325240 OS << *I << '\n';
52555263 OS << "\n";
52565264 }
52575265
5258 OS << "Determining loop execution counts for: " << F->getName() << "\n";
5266 OS << "Determining loop execution counts for: ";
5267 WriteAsOperand(OS, F, /*PrintType=*/false);
5268 OS << "\n";
52595269 for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)
52605270 PrintLoopInfo(OS, &SE, *I);
52615271 }
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output \
1 ; RUN: -scalar-evolution-max-iterations=0 | grep {Loop bb: backedge-taken count is 100}
1 ; RUN: -scalar-evolution-max-iterations=0 | grep {Loop %bb: backedge-taken count is 100}
22 ; PR1533
33
44 @array = weak global [101 x i32] zeroinitializer, align 32 ; <[100 x i32]*> [#uses=1]
None ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop bb: backedge-taken count is (-1 + (-1 \\* %x) + %y)}
0 ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop %bb: backedge-taken count is (-1 + (-1 \\* %x) + %y)}
11 ; PR1597
22
33 define i32 @f(i32 %x, i32 %y) {
None ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop header: backedge-taken count is (0 smax %n)}
0 ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop %header: backedge-taken count is (0 smax %n)}
11
22 define void @foo(i32 %n) {
33 entry:
None ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop loop: backedge-taken count is (100 + (-100 smax %n))}
0 ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop %loop: backedge-taken count is (100 + (-100 smax %n))}
11 ; PR2002
22
33 define void @foo(i8 %n) {
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output |& \
1 ; RUN: grep {Loop bb: backedge-taken count is (7 + (-1 \\* %argc))}
1 ; RUN: grep {Loop %bb: backedge-taken count is (7 + (-1 \\* %argc))}
22 ; XFAIL: *
33
44 define i32 @main(i32 %argc, i8** %argv) nounwind {
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output \
1 ; RUN: | grep {Loop bb: Unpredictable backedge-taken count\\.}
1 ; RUN: | grep {Loop %bb: Unpredictable backedge-taken count\\.}
22
33 ; ScalarEvolution can't compute a trip count because it doesn't know if
44 ; dividing by the stride will have a remainder. This could theoretically
None ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop bb3: backedge-taken count is (-1 + %n)}
0 ; RUN: opt < %s -scalar-evolution -analyze -disable-output | grep {Loop %bb3: backedge-taken count is (-1 + %n)}
11
22 ; We don't want to use a max in the trip count expression in
33 ; this testcase.
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output \
1 ; RUN: | grep {\{%d,+,\[^\{\}\]\*\}<bb>}
1 ; RUN: | grep {\{%d,+,\[^\{\}\]\*\}<%bb>}
22
33 ; ScalarEvolution should be able to understand the loop and eliminate the casts.
44
1717 %i.01 = phi i32 [ %16, %bb1 ], [ 0, %bb.nph ] ; [#uses=5]
1818
1919 ; CHECK: %1 = sext i32 %i.01 to i64
20 ; CHECK: --> {0,+,2}<bb>
20 ; CHECK: --> {0,+,2}<%bb>
2121 %1 = sext i32 %i.01 to i64 ; [#uses=1]
2222
2323 ; CHECK: %2 = getelementptr inbounds double* %d, i64 %1
24 ; CHECK: --> {%d,+,16}<bb>
24 ; CHECK: --> {%d,+,16}<%bb>
2525 %2 = getelementptr inbounds double* %d, i64 %1 ; [#uses=1]
2626
2727 %3 = load double* %2, align 8 ; [#uses=1]
3131 %7 = or i32 %i.01, 1 ; [#uses=1]
3232
3333 ; CHECK: %8 = sext i32 %7 to i64
34 ; CHECK: --> {1,+,2}<bb>
34 ; CHECK: --> {1,+,2}<%bb>
3535 %8 = sext i32 %7 to i64 ; [#uses=1]
3636
3737 ; CHECK: %9 = getelementptr inbounds double* %q, i64 %8
38 ; CHECK: {(8 + %q),+,16}<bb>
38 ; CHECK: {(8 + %q),+,16}<%bb>
3939 %9 = getelementptr inbounds double* %q, i64 %8 ; [#uses=1]
4040
4141 ; Artificially repeat the above three instructions, this time using
4343 %t7 = add nsw i32 %i.01, 1 ; [#uses=1]
4444
4545 ; CHECK: %t8 = sext i32 %t7 to i64
46 ; CHECK: --> {1,+,2}<bb>
46 ; CHECK: --> {1,+,2}<%bb>
4747 %t8 = sext i32 %t7 to i64 ; [#uses=1]
4848
4949 ; CHECK: %t9 = getelementptr inbounds double* %q, i64 %t8
50 ; CHECK: {(8 + %q),+,16}<bb>
50 ; CHECK: {(8 + %q),+,16}<%bb>
5151 %t9 = getelementptr inbounds double* %q, i64 %t8 ; [#uses=1]
5252
5353 %10 = load double* %9, align 8 ; [#uses=1]
7171 ret void
7272 }
7373
74 ; CHECK: Loop bb: backedge-taken count is ((-1 + %n) /u 2)
75 ; CHECK: Loop bb: max backedge-taken count is 1073741823
74 ; CHECK: Loop %bb: backedge-taken count is ((-1 + %n) /u 2)
75 ; CHECK: Loop %bb: max backedge-taken count is 1073741823
None ; RUN: opt < %s -analyze -scalar-evolution -disable-output | grep { --> {.*,+,.*}<bb>} | count 8
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output | grep { --> {.*,+,.*}<%bb>} | count 8
11
22 ; The addrecs in this loop are analyzable only by using nsw information.
33
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output > %t
1 ; RUN: grep {sext i57 \{0,+,199\} to i64} %t | count 1
2 ; RUN: grep {sext i59 \{0,+,199\}<bb> to i64} %t | count 1
1 ; RUN: grep {sext i57 \{0,+,199\}<%bb> to i64} %t | count 1
2 ; RUN: grep {sext i59 \{0,+,199\}<%bb> to i64} %t | count 1
33
44 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
55 target triple = "i386-apple-darwin9.6"
0 ; RUN: opt < %s -disable-output -scalar-evolution -analyze \
1 ; RUN: | grep { --> \{-128,+,1\}<bb1> Exits: 127} | count 5
1 ; RUN: | grep { --> \{-128,+,1\}<%bb1> Exits: 127} | count 5
22
33 ; Convert (sext {-128,+,1}) to {sext(-128),+,sext(1)}, since the
44 ; trip count is within range where this is safe.
0 ; RUN: opt < %s -disable-output -scalar-evolution -analyze \
1 ; RUN: | grep { --> (sext i. \{.\*,+,.\*\}<bb1> to i64)} | count 5
1 ; RUN: | grep { --> (sext i. \{.\*,+,.\*\}<%bb1> to i64)} | count 5
22
33 ; Don't convert (sext {...,+,...}) to {sext(...),+,sext(...)} in cases
44 ; where the trip count is not within range.
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output | FileCheck %s
11
22 ; CHECK: %tmp3 = sext i8 %tmp2 to i32
3 ; CHECK: --> (sext i8 {0,+,1}<bb1> to i32) Exits: -1
3 ; CHECK: --> (sext i8 {0,+,1}<%bb1> to i32) Exits: -1
44 ; CHECK: %tmp4 = mul i32 %tmp3, %i.02
5 ; CHECK: --> ((sext i8 {0,+,1}<bb1> to i32) * {0,+,1}) Exits: {0,+,-1}<bb>
5 ; CHECK: --> ((sext i8 {0,+,1}<%bb1> to i32) * {0,+,1}<%bb>) Exits: {0,+,-1}<%bb>
66
77 ; These sexts are not foldable.
88
0 ; RUN: opt < %s -scalar-evolution -analyze -disable-output \
1 ; RUN: | grep {Loop bb3\\.i: Unpredictable backedge-taken count\\.}
1 ; RUN: | grep {Loop %bb3\\.i: Unpredictable backedge-taken count\\.}
22
33 ; ScalarEvolution can't compute a trip count because it doesn't know if
44 ; dividing by the stride will have a remainder. This could theoretically
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output \
1 ; RUN: | grep {Loop bb7.i: Unpredictable backedge-taken count\\.}
1 ; RUN: | grep {Loop %bb7.i: Unpredictable backedge-taken count\\.}
22
33 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"
44
0 ; RUN: opt < %s -analyze -scalar-evolution -disable-output \
1 ; RUN: | grep {Loop for\\.body: backedge-taken count is (-1 + \[%\]ecx)}
1 ; RUN: | grep {Loop %for\\.body: backedge-taken count is (-1 + \[%\]ecx)}
22 ; PR4599
33
44 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"
1010
1111 ; This cast shouldn't be folded into the addrec.
1212 ; CHECK: %tmp = zext i8 %l_95.0.i1 to i16
13 ; CHECK: --> (zext i8 {0,+,-1}<bb.i> to i16) Exits: 2
13 ; CHECK: --> (zext i8 {0,+,-1}<%bb.i> to i16) Exits: 2
1414
1515 %tmp = zext i8 %l_95.0.i1 to i16
1616
0 ; RUN: opt < %s -scalar-evolution -analyze -disable-output \
1 ; RUN: | grep {\\--> (zext i4 {-7,+,-8}<loop> to i32)}
1 ; RUN: | grep {\\--> (zext i4 {-7,+,-8}<%loop> to i32)}
22
33 define fastcc void @foo() nounwind {
44 entry:
None ; RUN: opt < %s -analyze -iv-users -disable-output | grep {Stride i64 {3,+,2}<loop>:}
0 ; RUN: opt < %s -analyze -iv-users -disable-output | grep {Stride i64 {3,+,2}<%loop>:}
11
22 ; The value of %r is dependent on a polynomial iteration expression.
33