<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Perhaps there is another change in your tree.  We are looking at different code and/or I don’t know how your reference sequence for your test case. With fast-math and reassociation turned off I’m getting:<br class=""><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">        <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">vmovsd</span>  <span style="font-variant-ligatures: no-common-ligatures; color: #c33720" class="">8</span>(%<span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">rsp</span>), %<span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">xmm1</span>          <span style="font-variant-ligatures: no-common-ligatures; color: #5330e1" class=""># 8-byte Reload</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">                                        <span style="font-variant-ligatures: no-common-ligatures; color: #5330e1" class=""># xmm1 = mem[0],zero</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(83, 48, 225);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">        </span><span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">vaddsd</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">  </span><span style="font-variant-ligatures: no-common-ligatures; color: #c33720" class="">16</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(%</span><span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">rsp</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">), %</span><span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">xmm1</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, %</span><span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">xmm1</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">  </span># 8-byte Folded Reload</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">        <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">vaddsd</span>  (%<span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">rsp</span>), %<span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">xmm0</span>, %<span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">xmm0</span>    <span style="font-variant-ligatures: no-common-ligatures; color: #5330e1" class=""># 8-byte Folded Reload</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">        </span>vaddsd<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">  %</span>xmm0<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, %</span>xmm1<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">, %</span>xmm0</div><div class="">Which is happens to be the same code I get w/o fast-math.</div><div class=""><br class=""></div><div class="">That should not be faster than fast-math with reassociation.</div><div class=""><br class=""></div><div class="">I don’t understand why the equation *holds* although you measure a performance loss. I very much prefer a single equation that holds for all pattern.</div><div class=""><br class=""></div><div class="">-Gerolf</div><div class=""><br class=""></div><div class="">PS:</div><div class="">reassoc.ll</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(206, 121, 36);" class="">declare<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">@bar</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">()</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">define</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>@foo4_reassociated<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">() {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%a</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">call</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">@bar</span>()</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%b</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">call</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">@bar</span>()</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%c</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">call</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">@bar</span>()</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%d</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">call</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">@bar</span>()</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%t0</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">fadd</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%a</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%b</span><span style="font-variant-ligatures: no-common-ligatures; background-color: #af5f00" class=""> </span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%t1</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">fadd</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%c</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%d</span><span style="font-variant-ligatures: no-common-ligatures; background-color: #af5f00" class=""> </span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%t2</span> = <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">fadd</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%t0</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%t1</span><span style="font-variant-ligatures: no-common-ligatures; background-color: #af5f00" class=""> </span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">    <span style="font-variant-ligatures: no-common-ligatures; color: #ce7924" class="">ret</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bd26" class="">double</span> <span style="font-variant-ligatures: no-common-ligatures; color: #34bbc7" class="">%t2</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Oct 20, 2015, at 9:30 AM, Sanjay Patel <<a href="mailto:spatel@rotateright.com" class="">spatel@rotateright.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">spatel added a comment.<br class=""><br class="">In <a href="http://reviews.llvm.org/D13417#270790" class="">http://reviews.llvm.org/D13417#270790</a>, @Gerolf wrote:<br class=""><br class=""><blockquote type="cite" class="">Sorry, this has been a while. Please send me the instruction sequence you get w/ and w/o reassociation. Even w/o reassoc I see three dependent fadds (although there are four rather than three).<br class=""></blockquote><br class=""><br class="">I'm struggling to explain this any better than what is shown in the "already_reassociated()" test case included in this patch. Please let me know if there's some other format or some debug output that I can include for reference.<br class=""><br class="">With current (broken) reassociation, the expected sequence for  (a + b) + (c + d) is being changed from:<br class=""><br class="">  vaddsd  16(%rsp), %xmm1, %xmm1     <--- c + d<br class="">  vaddsd  (%rsp), %xmm0, %xmm0       <--- a + b              [independent]<br class="">  vaddsd  %xmm0, %xmm1, %xmm0        <--- (a + b) + (c + d)<br class=""><br class="">To:<br class=""><br class="">  vaddsd (%rsp), %xmm0, %xmm0        <--- a + b<br class="">  vaddsd 8(%rsp), %xmm0, %xmm0       <--- (a + b) + c        [dependent]<br class="">  vaddsd 16(%rsp), %xmm0, %xmm0      <--- ((a + b) + c) + d  [dependent]<br class=""><br class=""><br class=""><a href="http://reviews.llvm.org/D13417" class="">http://reviews.llvm.org/D13417</a><br class=""><br class=""><br class=""><br class=""></div></div></blockquote></div><br class=""></div></body></html>