<div dir="ltr"><div>Thanks very much, Renato!</div><div><br></div><div>I looked into the regressions, there're many cases have similar context as the case I mentioned but N just has only one use.</div><div>In this case, the canonicalisation won't make it more profitable, will only prevent the possible folding or</div><div>make the sequence is not expected.</div><div>The regressions be eliminated, after I limit the expanding to not "N->hasOneUse()".</div><div><br></div><div>And now only one regression left:</div><div><br></div><div><font color="#999999"> FAIL: LLVM :: CodeGen/Thumb2/machine-licm.ll (18865 of 29222)</font></div><div><font color="#999999">******************** TEST 'LLVM :: CodeGen/Thumb2/machine-licm.ll' FAILED ********************</font></div><div><font color="#999999">Script:</font></div><div><font color="#999999">--</font></div><div><font color="#999999">/home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/llc">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/llc</a> < /home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll</a> -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -disable-fp-elim | /home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/FileCheck">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/FileCheck</a> /home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll</a></font></div><div><font color="#999999">/home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/llc">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/llc</a> < /home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll</a> -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim | /home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/FileCheck">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/build/./bin/FileCheck</a> /home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll</a> --check-prefix=PIC</font></div><div><font color="#999999">--</font></div><div><font color="#999999">Exit Code: 1</font></div><div><font color="#999999"><br></font></div><div><font color="#999999">Command Output (stderr):</font></div><div><font color="#999999">--</font></div><div><font color="#999999">/home/likewise-open/SPREADTRUM/<a href="http://jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll:88:10">jojo.ma/jojoma/source/llvm/llvm-linaro/llvm/llvm/test/CodeGen/Thumb2/machine-licm.ll:88:10</a>: error: expected string not found in input</font></div><div><font color="#999999">; CHECK: movw {{(r[0-9])|(lr)}}, #32768</font></div><div><font color="#999999"> ^</font></div><div><font color="#999999"><stdin>:56:2: note: scanning from here</font></div><div><font color="#999999"> movw r12, #32768</font></div><div><font color="#999999"> ^</font></div><div><font color="#999999"><br></font></div><div>The outputs before and after the canonicalisation are:</div><div><ul><li>before canonicalisation<br></li></ul></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font color="#999999"> _t3:</font></div><div><font color="#999999">@ BB#0: @ %bb.nph</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>push<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>{r7, lr}</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>mov<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r7, sp</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movw<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>lr, #32768</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movs<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r2, #0</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movw<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r9, #16386</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movw<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r12, #65534</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movt<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>lr, #65535</font></div><div><font color="#999999">LBB2_1: @ %bb</font></div><div><font color="#999999"> @ =>This Inner Loop Header: Depth=1</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>eor.w<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, r0, r1</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>adds<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r2, #1</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ands<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, r3, #1</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>it<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ne</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>eorne.w<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r1, r1, r9</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>and.w<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, r1, r12</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>orr.w<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r1, lr, r3, lsr #1</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>it<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>eq</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>lsreq<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r1, r3, #1</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ubfx<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r0, r0, #1, #7</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>uxtb<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, r2</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>cmp<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, #8</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>bne<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>LBB2_1</font></div><div><font color="#999999">@ BB#2: @ %bb8</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>uxth<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r0, r1</font></div><div><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>pop<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>{r7, pc}</font></div></blockquote><div><ul><li>after canonicalisation</li></ul></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_extra"><font color="#999999">_t3:</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999">@ BB#0: @ %bb.nph</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movw<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r12, #32768</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movs<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r2, #0</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movw<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r9, #16386</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>movt<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r12, #65535</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999">LBB2_1: @ %bb</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"> @ =>This Inner Loop Header: Depth=1</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>eor.w<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, r0, r1</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>adds<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r2, #1</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ands<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, r3, #1</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>it<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ne</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>eorne.w<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r1, r1, r9</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>uxtb<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, r2</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ubfx<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r1, r1, #1, #15</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>it<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ne</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>orrne.w<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r1, r1, r12</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ubfx<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r0, r0, #1, #7</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>cmp<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r3, #8</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>bne<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>LBB2_1</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999">@ BB#2: @ %bb8</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>uxth<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>r0, r1</font></div></div><div class="gmail_extra"><div class="gmail_extra"><font color="#999999"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>bx<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>lr</font></div></div></blockquote><div class="gmail_extra"><div><br></div><div>The context of this is same with the case of CoreMa, so i can't rule it out in my change.</div><div>I created a review on phabricator of my proposal: </div><div><a href="https://reviews.llvm.org/D27916">https://reviews.llvm.org/D27916</a></div><div><br></div><div>Hope all the above could make the problem clear.</div><div>Welcome any review and advice.Thanks!</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Best Regards,<br></div>Jojo<br></div></div></div>
<br><div class="gmail_quote">On 15 December 2016 at 20:10, Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="gmail-">On 8 December 2016 at 02:34, Jojo Ma <<a href="mailto:jojo.ma@linaro.org">jojo.ma@linaro.org</a>> wrote:<br>
> It would be profitable as well if we could enable the canonicalisation on<br>
> it.<br>
> sequence before this canonicalisation (ARM):<br>
> test:<br>
> .fnstart<br>
> @ BB#0: @ %entry<br>
> movw r1, #65534<br>
> and r1, r0, r1<br>
> ubfx r0, r0, #1, #15<br>
> add r0, r0, r1, lsr #1<br>
> bx lr<br>
><br>
> sequence after this canonicalisation:<br>
> test:<br>
> .fnstart<br>
> @ BB#0: @ %entry<br>
> ubfx r0, r0, #1, #15<br>
> add r0, r0, r0<br>
> bx lr<br>
><br>
> But when I tried to expand the condition to this case, there are lots of<br>
> various regression fails.<br>
<br>
</span>Hi Jojo,<br>
<br>
I think this canonicalisation is correct, at least in this case, so<br>
it's quite possible that the regressions are just bad tests, or you<br>
actually made the code better in other places that weren't expecting<br>
it.<br>
<br>
I'm adding some folks that have worked on the DAG combiner recently to<br>
have a look, but it would be good to know what regressions were there<br>
to see if they're really regressions (ie. worse code) or just<br>
different/better code.<br>
<br>
You may also have missed a check on your code (which would wrongly<br>
combine constants). Can you create a review on Phab of your proposed<br>
change?<br>
<br>
Also, if you could list the regressions and see if they have a common<br>
pattern (ie. "tests expecting an additional mask failed", or "the<br>
wrong mask was applied"), it would become clearer if they are real<br>
regressions or not.<br>
<br>
cheers,<br>
--renato<br>
</blockquote></div><br></div></div>