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

Sanjoy Das sanjoy at playingwithpointers.com
Sat Mar 7 16:25:05 PST 2015


Hi atrick,

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

http://reviews.llvm.org/D8143

Files:
  lib/Analysis/ScalarEvolution.cpp

Index: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ lib/Analysis/ScalarEvolution.cpp
@@ -114,6 +114,12 @@
 VerifySCEV("verify-scev",
            cl::desc("Verify ScalarEvolution's backedge taken counts (slow)"));
 
+static cl::opt<bool>
+PrintConstantRanges("scalar-evolution-print-constant-ranges", cl::Hidden,
+                    cl::desc("Print constant range information when printing "
+                             "SCEVs via -analysis"),
+                    cl::init(false));
+
 INITIALIZE_PASS_BEGIN(ScalarEvolution, "scalar-evolution",
                 "Scalar Evolution Analysis", false, true)
 INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker)
@@ -8150,13 +8156,25 @@
       OS << "  -->  ";
       const SCEV *SV = SE.getSCEV(&*I);
       SV->print(OS);
+      if (PrintConstantRanges && !isa<SCEVCouldNotCompute>(SV)) {
+        OS << " U: ";
+        SE.getUnsignedRange(SV).print(OS);
+        OS << " S: ";
+        SE.getSignedRange(SV).print(OS);
+      }
 
       const Loop *L = LI->getLoopFor((*I).getParent());
 
       const SCEV *AtUse = SE.getSCEVAtScope(SV, L);
       if (AtUse != SV) {
         OS << "  -->  ";
         AtUse->print(OS);
+        if (PrintConstantRanges && !isa<SCEVCouldNotCompute>(AtUse)) {
+          OS << " U: ";
+          SE.getUnsignedRange(AtUse).print(OS);
+          OS << " S: ";
+          SE.getSignedRange(AtUse).print(OS);
+        }
       }
 
       if (L) {

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8143.21437.patch
Type: text/x-patch
Size: 1523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150308/32387cdc/attachment.bin>


More information about the llvm-commits mailing list