<font size="2"><span style="background-color:rgba(255,255,255,0)">r275468 fixed it for us. Thanks, Davide!</span></font><div><font size="2"><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);"><br></span></font></div><div><font size="2"><span style="background-color:rgba(255,255,255,0)"></span><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);">-- Matt<br></span></font><br>On Monday, July 18, 2016, Davide Italiano via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Are you still seeing problems?<br>
<br>
On Thu, Jul 14, 2016 at 1:34 PM, Davide Italiano <<a href="javascript:;" onclick="_e(event, 'cvml', 'davide@freebsd.org')">davide@freebsd.org</a>> wrote:<br>
> On Thu, Jul 14, 2016 at 12:27 PM, Matthew Simpson<br>
> <<a href="javascript:;" onclick="_e(event, 'cvml', 'mssimpso@codeaurora.org')">mssimpso@codeaurora.org</a>> wrote:<br>
>> Hi Davide,<br>
>><br>
>> We're seeing large compile-time regressions with this change and LTO when<br>
>> compiling spec2000/2006. For example, the compile-time of spec2000/crafty<br>
>> roughly doubles. Would you mind taking a look? We're compiling with "-Ofast<br>
>> -flto -fuse-ld=gold -mcpu=kryo". Please let me know if you're unable to<br>
>> reproduce. Thanks!<br>
>><br>
><br>
> Sorry about that, r275468 should help, please let me know if you still<br>
> have trouble!<br>
><br>
>> -- Matt<br>
>><br>
>><br>
>><br>
>> On Wed, Jul 13, 2016 at 10:34 PM, Davide Italiano via llvm-commits<br>
>> <<a href="javascript:;" onclick="_e(event, 'cvml', 'llvm-commits@lists.llvm.org')">llvm-commits@lists.llvm.org</a>> wrote:<br>
>>><br>
>>> On Wed, Jul 13, 2016 at 6:51 PM, Eli Friedman <<a href="javascript:;" onclick="_e(event, 'cvml', 'eli.friedman@gmail.com')">eli.friedman@gmail.com</a>><br>
>>> wrote:<br>
>>> > On Wed, Jul 13, 2016 at 6:27 PM, Davide Italiano via llvm-commits<br>
>>> > <<a href="javascript:;" onclick="_e(event, 'cvml', 'llvm-commits@lists.llvm.org')">llvm-commits@lists.llvm.org</a>> wrote:<br>
>>> >><br>
>>> >> Author: davide<br>
>>> >> Date: Wed Jul 13 20:27:29 2016<br>
>>> >> New Revision: 275357<br>
>>> >><br>
>>> >> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=275357&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=275357&view=rev</a><br>
>>> >> Log:<br>
>>> >> [SCCP] Generalize tryToReplaceInstWithConstant to work also with<br>
>>> >> arguments.<br>
>>> >><br>
>>> >> Modified:<br>
>>> >>     llvm/trunk/lib/Transforms/Scalar/SCCP.cpp<br>
>>> >><br>
>>> >> Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp<br>
>>> >> URL:<br>
>>> >><br>
>>> >> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=275357&r1=275356&r2=275357&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=275357&r1=275356&r2=275357&view=diff</a><br>
>>> >><br>
>>> >><br>
>>> >> ==============================================================================<br>
>>> >> --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)<br>
>>> >> +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Jul 13 20:27:29 2016<br>
>>> >> @@ -1510,16 +1510,16 @@ bool SCCPSolver::ResolvedUndefsIn(Functi<br>
>>> >>    return false;<br>
>>> >>  }<br>
>>> >><br>
>>> >> -static bool tryToReplaceInstWithConstant(SCCPSolver Solver,<br>
>>> >> Instruction<br>
>>> >> *Inst,<br>
>>> >> -                                         bool shouldEraseFromParent) {<br>
>>> >> +template <typename ArgOrInst><br>
>>> >> +static bool tryToReplaceWithConstant(SCCPSolver Solver, ArgOrInst *AI)<br>
>>> >> {<br>
>>> ><br>
>>> ><br>
>>> > Can you just use a Value* here?<br>
>>> ><br>
>>><br>
>>> Sure, I'll change that.<br>
>>><br>
>>> >><br>
>>> >>    Constant *Const = nullptr;<br>
>>> >> -  if (Inst->getType()->isStructTy()) {<br>
>>> >> -    std::vector<LatticeVal> IVs =<br>
>>> >> Solver.getStructLatticeValueFor(Inst);<br>
>>> >> +  if (AI->getType()->isStructTy()) {<br>
>>> >> +    std::vector<LatticeVal> IVs = Solver.getStructLatticeValueFor(AI);<br>
>>> >>      if (std::any_of(IVs.begin(), IVs.end(),<br>
>>> >>                      [](LatticeVal &LV) { return LV.isOverdefined();<br>
>>> >> }))<br>
>>> >>        return false;<br>
>>> >>      std::vector<Constant *> ConstVals;<br>
>>> >> -    StructType *ST = dyn_cast<StructType>(Inst->getType());<br>
>>> >> +    StructType *ST = dyn_cast<StructType>(AI->getType());<br>
>>> >>      for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) {<br>
>>> >>        LatticeVal V = IVs[i];<br>
>>> >>        ConstVals.push_back(V.isConstant()<br>
>>> >> @@ -1528,18 +1528,23 @@ static bool tryToReplaceInstWithConstant<br>
>>> >>      }<br>
>>> >>      Const = ConstantStruct::get(ST, ConstVals);<br>
>>> >>    } else {<br>
>>> >> -    LatticeVal IV = Solver.getLatticeValueFor(Inst);<br>
>>> >> +    LatticeVal IV = Solver.getLatticeValueFor(AI);<br>
>>> >>      if (IV.isOverdefined())<br>
>>> >>        return false;<br>
>>> >> -<br>
>>> >> -    Const =<br>
>>> >> -        IV.isConstant() ? IV.getConstant() :<br>
>>> >> UndefValue::get(Inst->getType());<br>
>>> >> +    Const = IV.isConstant() ? IV.getConstant() :<br>
>>> >> UndefValue::get(AI->getType());<br>
>>> >>    }<br>
>>> >>    assert(Const && "Constant is nullptr here!");<br>
>>> >> -  DEBUG(dbgs() << "  Constant: " << *Const << " = " << *Inst << '\n');<br>
>>> >> +  DEBUG(dbgs() << "  Constant: " << *Const << " = " << *AI << '\n');<br>
>>> >><br>
>>> >>    // Replaces all of the uses of a variable with uses of the constant.<br>
>>> >> -  Inst->replaceAllUsesWith(Const);<br>
>>> >> +  AI->replaceAllUsesWith(Const);<br>
>>> >> +  return true;<br>
>>> >> +}<br>
>>> >> +<br>
>>> >> +static bool tryToReplaceInstWithConstant(SCCPSolver Solver,<br>
>>> >> Instruction<br>
>>> >> *Inst,<br>
>>> >> +                                         bool shouldEraseFromParent) {<br>
>>> >> +  if (!tryToReplaceWithConstant(Solver, Inst))<br>
>>> >> +    return false;<br>
>>> >><br>
>>> >>    // Delete the instruction.<br>
>>> >>    if (shouldEraseFromParent)<br>
>>> >> @@ -1766,17 +1771,8 @@ static bool runIPSCCP(Module &M, const D<br>
>>> >>          // TODO: Could use getStructLatticeValueFor to find out if the<br>
>>> >> entire<br>
>>> >>          // result is a constant and replace it entirely if so.<br>
>>> >><br>
>>> >> -        LatticeVal IV = Solver.getLatticeValueFor(&*AI);<br>
>>> >> -        if (IV.isOverdefined()) continue;<br>
>>> >> -<br>
>>> >> -        Constant *CST = IV.isConstant() ?<br>
>>> >> -        IV.getConstant() : UndefValue::get(AI->getType());<br>
>>> >> -        DEBUG(dbgs() << "***  Arg " << *AI << " = " << *CST <<"\n");<br>
>>> >> -<br>
>>> >> -        // Replaces all of the uses of a variable with uses of the<br>
>>> >> -        // constant.<br>
>>> >> -        AI->replaceAllUsesWith(CST);<br>
>>> >> -        ++IPNumArgsElimed;<br>
>>> >> +        if (tryToReplaceWithConstant(Solver, &*AI))<br>
>>> >> +          ++IPNumArgsElimed;<br>
>>> >>        }<br>
>>> >>      }<br>
>>> ><br>
>>> ><br>
>>> > Testcase?<br>
>>> ><br>
>>><br>
>>> Sorry if I failed to mention on this commit, but this is NFC as we<br>
>>> skip the replacement phase if the argument is of struct type (unless<br>
>>> I'm missing something).<br>
>>> My next patch, <a href="http://reviews.llvm.org/D22329" target="_blank">http://reviews.llvm.org/D22329</a> , changes the behaviour<br>
>>> and add test cases.<br>
>>><br>
>>><br>
>>> Thanks for your review!<br>
>>><br>
>>> --<br>
>>> Davide<br>
>>><br>
>>> "There are no solved problems; there are only problems that are more<br>
>>> or less solved" -- Henri Poincare<br>
>>> _______________________________________________<br>
>>> llvm-commits mailing list<br>
>>> <a href="javascript:;" onclick="_e(event, 'cvml', 'llvm-commits@lists.llvm.org')">llvm-commits@lists.llvm.org</a><br>
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> Davide<br>
><br>
> "There are no solved problems; there are only problems that are more<br>
> or less solved" -- Henri Poincare<br>
<br>
<br>
<br>
--<br>
Davide<br>
<br>
"There are no solved problems; there are only problems that are more<br>
or less solved" -- Henri Poincare<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'llvm-commits@lists.llvm.org')">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>