<div dir="ltr"><span style="font-size:12.8000001907349px">Hello,</span><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Please see r247497 below for context.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Could anyone please shed some light on the specific reasons why MaxInstsToScan is set to '6'?</div><div style="font-size:12.8000001907349px">I need to increase the value, at least to '8' on the call of FindAvailableLoadedValue() from InstCombiner::visitLoadInst();</div><div style="font-size:12.8000001907349px">and I would like to know that this is a non-destructive change to make.</div><div style="font-size:12.8000001907349px">I am unable to access emails on the mailing list that go as far back as <span class="">r60148</span> (Nov 26, 2008) to dig up the reasons.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks,</div><div style="font-size:12.8000001907349px">-- Larisse.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 11, 2015 at 6:41 PM, Larisse Voufo via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lvoufo<br>
Date: Fri Sep 11 20:41:55 2015<br>
New Revision: 247497<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=247497&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=247497&view=rev</a><br>
Log:<br>
Clean up: Refactoring the hardcoded value of 6 for FindAvailableLoadedValue()'s parameter MaxInstsToScan.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/Analysis/Loads.h<br>
llvm/trunk/lib/Analysis/Lint.cpp<br>
llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp<br>
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/Loads.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Loads.h?rev=247497&r1=247496&r2=247497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Loads.h?rev=247497&r1=247496&r2=247497&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/Loads.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/Loads.h Fri Sep 11 20:41:55 2015<br>
@@ -29,15 +29,28 @@ class MDNode;<br>
bool isSafeToLoadUnconditionally(Value *V, Instruction *ScanFrom,<br>
unsigned Align);<br>
<br>
+/// DEF_MAX_INSTS_TO_SCAN - the default number of maximum instructions<br>
+/// to scan in the block, used by FindAvailableLoadedValue().<br>
+/// FindAvailableLoadedValue() was introduced in r60148, to improve jump<br>
+/// threading in part by eliminating partially redundant loads.<br>
+/// At that point, the value of MaxInstsToScan was already set to '6'<br>
+/// without documented explanation.<br>
+/// FIXME: Ask r60148 author for details, and complete this documentation.<br>
+/// NOTE: As of now, every use of FindAvailableLoadedValue() uses this default<br>
+/// value of '6'.<br>
+#ifndef DEF_MAX_INSTS_TO_SCAN<br>
+#define DEF_MAX_INSTS_TO_SCAN 6<br>
+#endif<br>
+<br>
/// FindAvailableLoadedValue - Scan the ScanBB block backwards (starting at<br>
/// the instruction before ScanFrom) checking to see if we have the value at<br>
/// the memory address *Ptr locally available within a small number of<br>
/// instructions. If the value is available, return it.<br>
///<br>
-/// If not, return the iterator for the last validated instruction that the<br>
+/// If not, return the iterator for the last validated instruction that the<br>
/// value would be live through. If we scanned the entire block and didn't<br>
/// find something that invalidates *Ptr or provides it, ScanFrom would be<br>
-/// left at begin() and this returns null. ScanFrom could also be left<br>
+/// left at begin() and this returns null. ScanFrom could also be left<br>
///<br>
/// MaxInstsToScan specifies the maximum instructions to scan in the block.<br>
/// If it is set to 0, it will scan the whole block. You can also optionally<br>
@@ -48,7 +61,7 @@ bool isSafeToLoadUnconditionally(Value *<br>
/// is found, it is left unmodified.<br>
Value *FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,<br>
BasicBlock::iterator &ScanFrom,<br>
- unsigned MaxInstsToScan = 6,<br>
+ unsigned MaxInstsToScan = DEF_MAX_INSTS_TO_SCAN,<br>
AliasAnalysis *AA = nullptr,<br>
AAMDNodes *AATags = nullptr);<br>
<br>
<br>
Modified: llvm/trunk/lib/Analysis/Lint.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=247497&r1=247496&r2=247497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=247497&r1=247496&r2=247497&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/Lint.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/Lint.cpp Fri Sep 11 20:41:55 2015<br>
@@ -829,8 +829,9 @@ Value *Lint::findValueImpl(Value *V, boo<br>
for (;;) {<br>
if (!VisitedBlocks.insert(BB).second)<br>
break;<br>
- if (Value *U = FindAvailableLoadedValue(L->getPointerOperand(),<br>
- BB, BBI, 6, AA))<br>
+ if (Value *U =<br>
+ FindAvailableLoadedValue(L->getPointerOperand(),<br>
+ BB, BBI, DEF_MAX_INSTS_TO_SCAN, AA))<br>
return findValueImpl(U, OffsetOk, Visited);<br>
if (BBI != BB->begin()) break;<br>
BB = BB->getUniquePredecessor();<br>
<br>
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=247497&r1=247496&r2=247497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=247497&r1=247496&r2=247497&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Fri Sep 11 20:41:55 2015<br>
@@ -750,8 +750,9 @@ Instruction *InstCombiner::visitLoadInst<br>
// separated by a few arithmetic operations.<br>
BasicBlock::iterator BBI = &LI;<br>
AAMDNodes AATags;<br>
- if (Value *AvailableVal = FindAvailableLoadedValue(Op, LI.getParent(), BBI,<br>
- 6, AA, &AATags)) {<br>
+ if (Value *AvailableVal =<br>
+ FindAvailableLoadedValue(Op, LI.getParent(), BBI,<br>
+ DEF_MAX_INSTS_TO_SCAN, AA, &AATags)) {<br>
if (LoadInst *NLI = dyn_cast<LoadInst>(AvailableVal)) {<br>
unsigned KnownIDs[] = {<br>
LLVMContext::MD_tbaa,<br>
@@ -822,7 +823,7 @@ Instruction *InstCombiner::visitLoadInst<br>
}<br>
<br>
// load (select (cond, null, P)) -> load P<br>
- if (isa<ConstantPointerNull>(SI->getOperand(1)) &&<br>
+ if (isa<ConstantPointerNull>(SI->getOperand(1)) &&<br>
LI.getPointerAddressSpace() == 0) {<br>
LI.setOperand(0, SI->getOperand(2));<br>
return &LI;<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=247497&r1=247496&r2=247497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=247497&r1=247496&r2=247497&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Sep 11 20:41:55 2015<br>
@@ -769,7 +769,7 @@ bool JumpThreading::ProcessBlock(BasicBl<br>
// If we're branching on a conditional, LVI might be able to determine<br>
// it's value at the branch instruction. We only handle comparisons<br>
// against a constant at this time.<br>
- // TODO: This should be extended to handle switches as well.<br>
+ // TODO: This should be extended to handle switches as well.<br>
BranchInst *CondBr = dyn_cast<BranchInst>(BB->getTerminator());<br>
Constant *CondConst = dyn_cast<Constant>(CondCmp->getOperand(1));<br>
if (CondBr && CondConst && CondBr->isConditional()) {<br>
@@ -877,7 +877,7 @@ bool JumpThreading::SimplifyPartiallyRed<br>
BasicBlock::iterator BBIt = LI;<br>
<br>
if (Value *AvailableVal =<br>
- FindAvailableLoadedValue(LoadedPtr, LoadBB, BBIt, 6)) {<br>
+ FindAvailableLoadedValue(LoadedPtr, LoadBB, BBIt)) {<br>
// If the value if the load is locally available within the block, just use<br>
// it. This frequently occurs for reg2mem'd allocas.<br>
//cerr << "LOAD ELIMINATED:\n" << *BBIt << *LI << "\n";<br>
@@ -922,7 +922,8 @@ bool JumpThreading::SimplifyPartiallyRed<br>
// Scan the predecessor to see if the value is available in the pred.<br>
BBIt = PredBB->end();<br>
AAMDNodes ThisAATags;<br>
- Value *PredAvailable = FindAvailableLoadedValue(LoadedPtr, PredBB, BBIt, 6,<br>
+ Value *PredAvailable = FindAvailableLoadedValue(LoadedPtr, PredBB, BBIt,<br>
+ DEF_MAX_INSTS_TO_SCAN,<br>
nullptr, &ThisAATags);<br>
if (!PredAvailable) {<br>
OneUnavailablePred = PredBB;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>