[SCEV] Add a `scalar-evolution-print-constant-ranges' option

Summary:
Unused in this commit, but will be used in a subsequent change (D8142)
by a FileCheck test.

Reviewers: atrick

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8143

llvm-svn: 231708
This commit is contained in:
Sanjoy Das 2015-03-09 21:43:39 +00:00
parent ad11d4c196
commit f257452986
9 changed files with 32 additions and 20 deletions

View File

@ -8150,6 +8150,12 @@ void ScalarEvolution::print(raw_ostream &OS, const Module *) const {
OS << " --> ";
const SCEV *SV = SE.getSCEV(&*I);
SV->print(OS);
if (!isa<SCEVCouldNotCompute>(SV)) {
OS << " U: ";
SE.getUnsignedRange(SV).print(OS);
OS << " S: ";
SE.getSignedRange(SV).print(OS);
}
const Loop *L = LI->getLoopFor((*I).getParent());
@ -8157,6 +8163,12 @@ void ScalarEvolution::print(raw_ostream &OS, const Module *) const {
if (AtUse != SV) {
OS << " --> ";
AtUse->print(OS);
if (!isa<SCEVCouldNotCompute>(AtUse)) {
OS << " U: ";
SE.getUnsignedRange(AtUse).print(OS);
OS << " S: ";
SE.getSignedRange(AtUse).print(OS);
}
}
if (L) {

View File

@ -34,7 +34,7 @@ loop:
%rand2 = icmp ugt i32 %A, %Z1
%Z2 = select i1 %rand2, i32 %A, i32 %Z1
; CHECK: %Z2 =
; CHECK-NEXT: --> ([[EXPR:.*]]){{ +}}Exits: 20
; CHECK-NEXT: --> ([[EXPR:.*]]){{ U: [^ ]+ S: [^ ]+}}{{ +}}Exits: 20
%B = trunc i32 %Z2 to i16
%C = sext i16 %B to i30
; CHECK: %C =

View File

@ -14,14 +14,14 @@ entry:
for.body: ; preds = %entry, %for.body
%sum.04 = phi i32 [ 0, %entry ], [ %add2, %for.body ]
; CHECK: --> %sum.04{{ *}}Exits: 2450
; CHECK: --> %sum.04{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 2450
%i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%arrayidx = getelementptr inbounds [50 x i32], [50 x i32]* @arr1, i32 0, i32 %i.03
%0 = load i32, i32* %arrayidx, align 4
; CHECK: --> %0{{ *}}Exits: 50
; CHECK: --> %0{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 50
%arrayidx1 = getelementptr inbounds [50 x i32], [50 x i32]* @arr2, i32 0, i32 %i.03
%1 = load i32, i32* %arrayidx1, align 4
; CHECK: --> %1{{ *}}Exits: 0
; CHECK: --> %1{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 0
%add = add i32 %0, %sum.04
%add2 = add i32 %add, %1
%inc = add nsw i32 %i.03, 1
@ -48,15 +48,15 @@ entry:
for.body: ; preds = %entry, %for.body
%sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ]
; CHECK: --> %sum.02{{ *}}Exits: 10
; CHECK: --> %sum.02{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 10
%n.01 = phi %struct.ListNode* [ bitcast ({ %struct.ListNode*, i32, [4 x i8] }* @node5 to %struct.ListNode*), %entry ], [ %1, %for.body ]
; CHECK: --> %n.01{{ *}}Exits: @node1
; CHECK: --> %n.01{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: @node1
%i = getelementptr inbounds %struct.ListNode, %struct.ListNode* %n.01, i64 0, i32 1
%0 = load i32, i32* %i, align 4
%add = add nsw i32 %0, %sum.02
%next = getelementptr inbounds %struct.ListNode, %struct.ListNode* %n.01, i64 0, i32 0
%1 = load %struct.ListNode*, %struct.ListNode** %next, align 8
; CHECK: --> %1{{ *}}Exits: 0
; CHECK: --> %1{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 0
%cmp = icmp eq %struct.ListNode* %1, null
br i1 %cmp, label %for.end, label %for.body

View File

@ -4,7 +4,7 @@
target datalayout = "e-p:32:32:32-p1:16:16:16-p2:8:8:8-p4:64:64:64-n16:32:64"
; CHECK: {%d,+,4}<%bb> Exits: ((4 * (trunc i32 (-1 + %n) to i16)) + %d)
; CHECK: {%d,+,4}<%bb>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: ((4 * (trunc i32 (-1 + %n) to i16)) + %d)
define void @foo(i32 addrspace(1)* nocapture %d, i32 %n) nounwind {

View File

@ -124,7 +124,7 @@ exit:
}
; CHECK-LABEL: PR12375
; CHECK: --> {(4 + %arg),+,4}<nuw><%bb1> Exits: (8 + %arg)<nsw>
; CHECK: --> {(4 + %arg),+,4}<nuw><%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (8 + %arg)<nsw>
define i32 @PR12375(i32* readnone %arg) {
bb:
%tmp = getelementptr inbounds i32, i32* %arg, i64 2
@ -143,7 +143,7 @@ bb7: ; preds = %bb1
}
; CHECK-LABEL: PR12376
; CHECK: --> {(4 + %arg),+,4}<nuw><%bb2> Exits: (4 + (4 * ((3 + (-1 * %arg) + (%arg umax %arg1)) /u 4)) + %arg)
; CHECK: --> {(4 + %arg),+,4}<nuw><%bb2>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (4 + (4 * ((3 + (-1 * %arg) + (%arg umax %arg1)) /u 4)) + %arg)
define void @PR12376(i32* nocapture %arg, i32* nocapture %arg1) {
bb:
br label %bb2
@ -161,7 +161,7 @@ bb5: ; preds = %bb2
declare void @f(i32)
; CHECK-LABEL: nswnowrap
; CHECK: --> {(1 + %v),+,1}<nsw><%for.body> Exits: (2 + %v)
; CHECK: --> {(1 + %v),+,1}<nsw><%for.body>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: (2 + %v)
define void @nswnowrap(i32 %v) {
entry:
%add = add nsw i32 %v, 1

View File

@ -13,16 +13,16 @@ bb1.thread:
bb1: ; preds = %bb1, %bb1.thread
%i.0.reg2mem.0 = phi i64 [ -128, %bb1.thread ], [ %8, %bb1 ] ; <i64> [#uses=3]
; CHECK: %i.0.reg2mem.0
; CHECK-NEXT: --> {-128,+,1}<%bb1> Exits: 127
; CHECK-NEXT: --> {-128,+,1}<%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 127
%0 = trunc i64 %i.0.reg2mem.0 to i8 ; <i8> [#uses=1]
; CHECK: %0
; CHECK-NEXT: --> {-128,+,1}<%bb1> Exits: 127
; CHECK-NEXT: --> {-128,+,1}<%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 127
%1 = trunc i64 %i.0.reg2mem.0 to i9 ; <i8> [#uses=1]
; CHECK: %1
; CHECK-NEXT: --> {-128,+,1}<%bb1> Exits: 127
; CHECK-NEXT: --> {-128,+,1}<%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 127
%2 = sext i9 %1 to i64 ; <i64> [#uses=1]
; CHECK: %2
; CHECK-NEXT: --> {-128,+,1}<nsw><%bb1> Exits: 127
; CHECK-NEXT: --> {-128,+,1}<nsw><%bb1>{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 127
%3 = getelementptr double, double* %x, i64 %2 ; <double*> [#uses=1]
%4 = load double, double* %3, align 8 ; <double> [#uses=1]
%5 = fmul double %4, 3.900000e+00 ; <double> [#uses=1]

View File

@ -1,9 +1,9 @@
; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s
; CHECK: %tmp3 = sext i8 %tmp2 to i32
; CHECK: --> (sext i8 {0,+,1}<%bb1> to i32) Exits: -1
; CHECK: --> (sext i8 {0,+,1}<%bb1> to i32){{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: -1
; CHECK: %tmp4 = mul i32 %tmp3, %i.02
; CHECK: --> ((sext i8 {0,+,1}<%bb1> to i32) * {0,+,1}<%bb>) Exits: {0,+,-1}<%bb>
; CHECK: --> ((sext i8 {0,+,1}<%bb1> to i32) * {0,+,1}<%bb>){{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: {0,+,-1}<%bb>
; These sexts are not foldable.

View File

@ -13,7 +13,7 @@ entry:
for.cond: ; preds = %for.inc, %entry
%sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
; CHECK: --> %sum.0 Exits: 28
; CHECK: --> %sum.0{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 28
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
%cmp = icmp ult i32 %i.0, 8
br i1 %cmp, label %for.inc, label %for.end
@ -36,7 +36,7 @@ entry:
for.cond: ; preds = %for.inc, %entry
%sum.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
; CHECK: --> %sum.0 Exits: 28
; CHECK: --> %sum.0{{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 28
%i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
%cmp = icmp ult i32 %i.0, 8
br i1 %cmp, label %for.inc, label %for.end

View File

@ -10,7 +10,7 @@ bb.i: ; preds = %bb1.i, %bb.nph
; This cast shouldn't be folded into the addrec.
; CHECK: %tmp = zext i8 %l_95.0.i1 to i16
; CHECK: --> (zext i8 {0,+,-1}<%bb.i> to i16) Exits: 2
; CHECK: --> (zext i8 {0,+,-1}<%bb.i> to i16){{ U: [^ ]+ S: [^ ]+}}{{ *}}Exits: 2
%tmp = zext i8 %l_95.0.i1 to i16