Clean up: Refactoring the hardcoded value of 6 for FindAvailableLoadedValue()'s param...
[oota-llvm.git] / include / llvm / Analysis / Loads.h
index 698b665a93ff4ddd34c743893cf1b2825fe5ac81..3107a7659921e9c41bf25ef1f4f2734377262ee1 100644 (file)
@@ -29,15 +29,28 @@ class MDNode;
 bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
                                  unsigned Align);
 
+/// DEF_MAX_INSTS_TO_SCAN - the default number of maximum instructions
+/// to scan in the block, used by FindAvailableLoadedValue().
+/// FindAvailableLoadedValue() was introduced in r60148, to improve jump
+/// threading in part by eliminating partially redundant loads.
+/// At that point, the value of MaxInstsToScan was already set to '6'
+/// without documented explanation.
+/// FIXME: Ask r60148 author for details, and complete this documentation.
+/// NOTE: As of now, every use of FindAvailableLoadedValue() uses this default
+/// value of '6'.
+#ifndef DEF_MAX_INSTS_TO_SCAN
+#define DEF_MAX_INSTS_TO_SCAN 6
+#endif
+
 /// FindAvailableLoadedValue - Scan the ScanBB block backwards (starting at
 /// the instruction before ScanFrom) checking to see if we have the value at
 /// the memory address *Ptr locally available within a small number of
 ///  instructions. If the value is available, return it.
 ///
-/// If not, return the iterator for the last validated instruction that the 
+/// If not, return the iterator for the last validated instruction that the
 /// value would be live through.  If we scanned the entire block and didn't
 /// find something that invalidates *Ptr or provides it, ScanFrom would be
-/// left at begin() and this returns null.  ScanFrom could also be left 
+/// left at begin() and this returns null.  ScanFrom could also be left
 ///
 /// MaxInstsToScan specifies the maximum instructions to scan in the block.
 /// If it is set to 0, it will scan the whole block. You can also optionally
@@ -48,7 +61,7 @@ bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,
 /// is found, it is left unmodified.
 Value *FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
                                 BasicBlock::iterator &ScanFrom,
-                                unsigned MaxInstsToScan = 6,
+                                unsigned MaxInstsToScan = DEF_MAX_INSTS_TO_SCAN,
                                 AliasAnalysis *AA = nullptr,
                                 AAMDNodes *AATags = nullptr);