<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 19, 2016 at 3:57 PM, Wei Mi via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@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">SCEV expansion sometimes generates redundent expr even if there is an<br>
available expr which can be reused. The redundent exprs can be a lot<br>
different from existing exprs so that existing cleanup passes cannot<br>
remove them.<br>
<br>
<a href="https://llvm.org/bugs/show_bug.cgi?id=24920" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_<wbr>bug.cgi?id=24920</a><br>
<a href="https://llvm.org/bugs/show_bug.cgi?id=24442" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_<wbr>bug.cgi?id=24442</a><br>
<br>
<a href="https://reviews.llvm.org/D12090" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D12090</a> and <a href="https://reviews.llvm.org/D21313" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D21313</a><br>
already relieved the problem somewhat, but it is far from being solved<br>
fundamentally. Recently we found another problematic case described in<br>
<a href="https://llvm.org/bugs/show_bug.cgi?id=29065" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_<wbr>bug.cgi?id=29065</a>. And I believe I can<br>
create more tests revealing similar problems.  In PR29065, I explained<br>
why it is difficult to fix the problem by extending D12090 and D21313.<br>
It is possible but still not very easy to fix the problem by enhancing<br>
existing cleanup passes. So I am soliciting ideas here about how to<br>
solve the problem in a more fundamental way.<br>
<br>
One thing I am always wondering is GCC also uses SCEV to calculate the<br>
loop iteration number and why it doesn't have such problem. From my<br>
limited knowledge about GCC's SCEV I guess it is because gcc only has<br>
the basic function of SCEV which can represent loop recursive expr<br>
like llvm SCEVAddRecExpr part, SCEV operands are still gimple<br>
variables and it doesn't have such complex transformations on SCEV as<br>
llvm does.</blockquote><div><br></div><div>This is not really correct :)</div><div><br></div><div>In fact, at one point, GCC had *all of the possible scev* (sebastian worked a lot on it) ,including mixers, etc.</div><div><br></div><div><br></div><div>The real thing here is that  GCC just doesn't do a lot of scev expansion. It mainly uses it as an analysis, not as a code generation mechanism.</div><div><br></div><div><br></div></div></div></div>