<div dir="ltr"><div>Hi -</div><div><br></div><div>I don't know much about Hexagon, but I'm probably responsible ( <a href="https://reviews.llvm.org/D57789">https://reviews.llvm.org/D57789</a> and follow-ons) for the CGP difference that you are seeing.</div><div><br></div><div>There are a couple of ways to deal with this:</div><div>1. Adjust the target hook that controls this transform to return 'false' if there is a better alternative:<br></div><div>  /// Try to convert math with an overflow comparison into the corresponding DAG<br>  /// node operation. Targets may want to override this independently of whether<br>  /// the operation is legal/custom for the given type because it may obscure<br>  /// matching of other patterns.<br>  virtual bool shouldFormOverflowOp(unsigned Opcode, EVT VT) const {<br></div><div><br></div><div>2. Enhance the pattern-matching that forms a hardware loop to accept the overflow intrinsics.</div><div><br></div><div>Either way, please file bugs and/or add some regression tests for the problem cases on these targets. If those had existed before, I would have noticed the problem and tried to solve it as part of the initial change.<br></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 30, 2019 at 1:04 PM Joan Lluch via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">Hi All,<div><br></div><div>The following code :</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="color:rgb(186,45,162)">void</span> hexagon2( <span style="color:rgb(186,45,162)">int</span> *a, <span style="color:rgb(186,45,162)">int</span> *res )</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">  <span style="color:rgb(186,45,162)">int</span> i = <span style="color:rgb(39,42,216)">100</span>; </div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">  <span style="color:rgb(186,45,162)">while</span> ( i-- ) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">    *res++ = *a++;</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">  }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">}</div></div><div><br></div><div>gets compiled as a sub-optimal Software loop on LLVM 9.0 instead of a Hardware loop, whereas it was compiled as a Hardware Loop in LLVM 7.0. </div><div><br></div><div><br></div><div>This is the final assembly code generated by LLVM 9.0 :</div><div><br></div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>.text</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(209,47,27);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>.file<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span></span>"main.c"</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">  </span>.globl<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">      </span>hexagon2                <span style="color:rgb(0,132,0)">// -- Begin function hexagon2</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">      </span>.p2align<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span><span style="color:rgb(39,42,216)">2</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>.type<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>hexagon2,@function</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">hexagon2:                               <span style="color:rgb(0,132,0)">// @hexagon2</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)">// %bb.0:                               // %entry.old</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap"> </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>p0 = cmp.gtu(r0,r1); if (p0.new) jump:nt .LBB0_<span style="color:rgb(39,42,216)">5</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">         </span>r2 = r0</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">          </span>allocframe(<span style="color:rgb(0,132,0)">#0)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">   </span>}                               </span>// encoding: [A,0x41'A',A,0x15'A',0x00,0x3c,0x02,0x70]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B9_PCREL</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)">// %bb.1:                               // %entry.old</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>r0 = sub(r1,r0)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>}                               </span>// encoding: [0x00,0xc1,0x20,0xf3]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">   </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>if (p0.new) jump:nt .LBB0_<span style="color:rgb(39,42,216)">5</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">              </span>p0 = <a href="http://cmp.gt" target="_blank">cmp.gt</a>(r0,<span style="color:rgb(0,132,0)">#399)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap"> </span>}                               </span>// encoding: [A,0x48'A',A,0x5c'A',0xe0,0xf1,0x40,0x75]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B15_PCREL</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)">// %bb.2:</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">  </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>r0 = <span style="color:rgb(0,132,0)">#-100</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>}                               </span>// encoding: [0x80,0xf3,0xdf,0x78]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">.LBB0_<span style="color:rgb(39,42,216)">3</span>:                                <span style="color:rgb(0,132,0)">// %while.body</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">                                        <span style="color:rgb(0,132,0)">// =>This Inner Loop Header: Depth=1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>r3 = add(r0,<span style="color:rgb(0,132,0)">#1)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>r4 = memw(r2++<span style="color:rgb(0,132,0)">#4)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>memw(r1++</span>#4) = r4.new</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">     </span>}                               </span>// encoding: [0x23,0x40,0x00,0xb0,0x24,0x40,0x82,0x9b,0x08,0xd2,0xa1,0xab]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">   </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>p0 = cmp.gtu(r0,r3); if (!p0.new) jump:t .LBB0_<span style="color:rgb(39,42,216)">3</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">         </span>r0 = r3</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>}                               </span>// encoding: [A,0x63'A',0x40'A',0x15'A',0x00,0xc0,0x63,0x70]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: .LBB0_3, kind: fixup_Hexagon_B9_PCREL</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)">// %bb.4:                               // %while.end</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">  </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>r31:<span style="color:rgb(39,42,216)">30</span> = dealloc_return(r30):raw</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>}                               </span>// encoding: [0x1e,0xc0,0x1e,0x96]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">.LBB0_<span style="color:rgb(39,42,216)">5</span>:                                <span style="color:rgb(0,132,0)">// %while.body.rtli</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>call memmove</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">             </span>r1:<span style="color:rgb(39,42,216)">0</span> = combine(r2,r1)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>r2 = <span style="color:rgb(0,132,0)">#400</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>}                               </span>// encoding: [A,0x40'A',A,0x5a'A',0x00,0x41,0x02,0xf5,0x02,0xf2,0x00,0x78]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: memmove, kind: fixup_Hexagon_B22_PCREL</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">     </span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>r31:<span style="color:rgb(39,42,216)">30</span> = dealloc_return(r30):raw</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;color:rgb(0,132,0);background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>}                               </span>// encoding: [0x1e,0xc0,0x1e,0x96]</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">.Lfunc_end0:</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>.size<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>hexagon2, .Lfunc_end0-hexagon2</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)">                                        <span style="color:rgb(0,132,0)">// -- End function</span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="color:rgb(0,132,0)"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="font-family:Helvetica;font-size:12px"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="font-family:Helvetica;font-size:12px"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="font-family:Helvetica;font-size:12px">This is the assembly code generated by LLVM 7.0 :</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><span style="font-family:Helvetica;font-size:12px"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Monaco;background-color:rgb(255,255,255)"><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>.text</div><div style="margin:0px;line-height:normal;color:rgb(209,47,27)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>.file<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span></span>"main.c"</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">      </span>.globl<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">      </span>hexagon2                <span style="color:rgb(0,132,0)">// -- Begin function hexagon2</span></div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">  </span>.p2align<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span><span style="color:rgb(39,42,216)">2</span></div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>.type<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>hexagon2,@function</div><div style="margin:0px;line-height:normal">hexagon2:                               <span style="color:rgb(0,132,0)">// @hexagon2</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)">// %bb.0:                               // %entry.old</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">     </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>p0 = cmp.gtu(r0,r1); if (p0.new) jump:nt .LBB0_<span style="color:rgb(39,42,216)">5</span></div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">             </span>r2 = r0</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">              </span>allocframe(<span style="color:rgb(0,132,0)">#0)</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>}                               </span>// encoding: [A,0x41'A',A,0x15'A',0x00,0x3c,0x02,0x70]</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B9_PCREL</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)">// %bb.1:                               // %entry.old</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>r0 = sub(r1,r0)</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>}                               </span>// encoding: [0x00,0xc1,0x20,0xf3]</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>if (p0.new) jump:nt .LBB0_<span style="color:rgb(39,42,216)">5</span></div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">          </span>p0 = <a href="http://cmp.gt" target="_blank">cmp.gt</a>(r0,<span style="color:rgb(0,132,0)">#399)</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">     </span>}                               </span>// encoding: [A,0x48'A',A,0x5c'A',0xe0,0xf1,0x40,0x75]</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B15_PCREL</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)">// %bb.2:                               // %while.body.preheader</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">        </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>loop0(.LBB0_<span style="color:rgb(39,42,216)">3</span>,<span style="color:rgb(0,132,0)">#100)</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">  </span>}                               </span>// encoding: [0x20'A',0xc0'A',0x03'A',0x69'A']</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: .LBB0_3, kind: fixup_Hexagon_B7_PCREL</div><div style="margin:0px;line-height:normal">.Ltmp0:                                 <span style="color:rgb(0,132,0)">// Block address taken</span></div><div style="margin:0px;line-height:normal">.LBB0_<span style="color:rgb(39,42,216)">3</span>:                                <span style="color:rgb(0,132,0)">// %while.body</span></div><div style="margin:0px;line-height:normal">                                        <span style="color:rgb(0,132,0)">// =>This Inner Loop Header: Depth=1</span></div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>r0 = memw(r2++<span style="color:rgb(0,132,0)">#4)</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>memw(r1++</span>#4) = r0.new</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap"> </span>} :endloop0                     </span>// encoding: [0x20,0x80,0x82,0x9b,0x08,0xd2,0xa1,0xab]</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)">// %bb.4:                               // %while.end</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">  </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>r31:<span style="color:rgb(39,42,216)">30</span> = dealloc_return(r30):raw</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">   </span>}                               </span>// encoding: [0x1e,0xc0,0x1e,0x96]</div><div style="margin:0px;line-height:normal">.LBB0_<span style="color:rgb(39,42,216)">5</span>:                                <span style="color:rgb(0,132,0)">// %while.body.rtli</span></div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>call memmove</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">         </span>r1:<span style="color:rgb(39,42,216)">0</span> = combine(r2,r1)</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">                </span>r2 = <span style="color:rgb(0,132,0)">#400</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>}                               </span>// encoding: [A,0x40'A',A,0x5a'A',0x00,0x41,0x02,0xf5,0x02,0xf2,0x00,0x78]</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)">                                        </span>//   fixup A - offset: 0, value: memmove, kind: fixup_Hexagon_B22_PCREL</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">     </span>{</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">            </span>r31:<span style="color:rgb(39,42,216)">30</span> = dealloc_return(r30):raw</div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">   </span>}                               </span>// encoding: [0x1e,0xc0,0x1e,0x96]</div><div style="margin:0px;line-height:normal">.Lfunc_end0:</div><div style="margin:0px;line-height:normal"><span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">    </span>.size<span class="gmail-m_9040587224429194522Apple-tab-span" style="white-space:pre-wrap">       </span>hexagon2, .Lfunc_end0-hexagon2</div><div style="margin:0px;line-height:normal">                                        <span style="color:rgb(0,132,0)">// -- End function</span></div><div><span style="color:rgb(0,132,0)"><br></span></div><div><span style="color:rgb(0,132,0)"><br></span></div><div><div style="font-family:Helvetica;font-size:12px">The code generated by LLVM 7.0 is better than LLVM 9.0 because 9.0 did not made use of Hardware loops.  This is in my opinion a bad regression from some earlier version. This is not an isolated case, more cases of the same LLVM 9 ‘defect’ are easy to find.</div></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">I have investigated the issue and I identified the root cause of it, which is related with the initial use of the “llvm.uadd" intrinsic in LLVM 9.0 to increment the loop Induction Variable, instead of an “add” instruction like LLVM 7.0. </div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">This is the while.body excerpt after "CodeGen Prepare” in LLVM 9.0</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">while.body:                                       ; preds = %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">entry.old</span><span style="font-variant-ligatures:no-common-ligatures">, %while.body</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %lsr.iv = phi i32 [ </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">%math</span><span style="font-variant-ligatures:no-common-ligatures">, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">while.body</span><span style="font-variant-ligatures:no-common-ligatures"> ], [ </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">-100</span><span style="font-variant-ligatures:no-common-ligatures">, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">entry.old</span><span style="font-variant-ligatures:no-common-ligatures"> ]</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %res.addr.04 = phi i32* [ %cgep1, %while.body ], [ %res, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">entry.old</span><span style="font-variant-ligatures:no-common-ligatures"> ]</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %a.addr.03 = phi i32* [ %cgep, %while.body ], [ %a, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">entry.old</span><span style="font-variant-ligatures:no-common-ligatures"> ]</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %6 = load i32, i32* %a.addr.03, align 4, !tbaa !2</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  store i32 %6, i32* %res.addr.04, align 4, !tbaa !2</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">7</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">call</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">{</span><span style="font-variant-ligatures:no-common-ligatures"> i32</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">,</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">i1 } @llvm.uadd.with.overflow.i32(i32 </span><span style="font-variant-ligatures:no-common-ligatures">%lsr.iv, </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">i32 </span><span style="font-variant-ligatures:no-common-ligatures">1</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">math</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">extractvalue</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">{</span><span style="font-variant-ligatures:no-common-ligatures"> i32</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">,</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">i1 } </span><span style="font-variant-ligatures:no-common-ligatures">%</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">7</span><span style="font-variant-ligatures:no-common-ligatures">, 0</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(212,237,244)"><span style="font-variant-ligatures:no-common-ligatures">  %ov = extractvalue { i32, i1 } %7, 1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %cgep = getelementptr inbounds i32, i32* %a.addr.03, i32 1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %cgep1 = getelementptr inbounds i32, i32* %res.addr.04, i32 1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  br i1 %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">ov</span><span style="font-variant-ligatures:no-common-ligatures">, label %while.end, label %while.body</span></div></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">And this is the same excerpt on  LLVM 7.0</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">while.body:                                       ; preds = %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">while.body.preheader</span><span style="font-variant-ligatures:no-common-ligatures">, %while.body</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %lsr.iv = phi i32 [ </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">-100</span><span style="font-variant-ligatures:no-common-ligatures">, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">while.body.preheader</span><span style="font-variant-ligatures:no-common-ligatures"> ], [ </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">%lsr.iv.next</span><span style="font-variant-ligatures:no-common-ligatures">, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">while.body</span><span style="font-variant-ligatures:no-common-ligatures"> ]</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %res.addr.04 = phi i32* [ %cgep1, %while.body ], [ %res, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">while.body.preheader</span><span style="font-variant-ligatures:no-common-ligatures"> ]</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %a.addr.03 = phi i32* [ %cgep, %while.body ], [ %a, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">while.body.preheader</span><span style="font-variant-ligatures:no-common-ligatures"> ]</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %6 = load i32, i32* %a.addr.03, align 4, !tbaa !2</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  store i32 %6, i32* %res.addr.04, align 4, !tbaa !2</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">lsr.iv.next</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">add</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">nsw</span><span style="font-variant-ligatures:no-common-ligatures"> i32 %lsr.iv, 1</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">tobool</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">icmp</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">eq</span><span style="font-variant-ligatures:no-common-ligatures"> i32 %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">lsr.iv.next</span><span style="font-variant-ligatures:no-common-ligatures">, 0</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %cgep = getelementptr inbounds i32, i32* %a.addr.03, i32 1</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  %cgep1 = getelementptr inbounds i32, i32* %res.addr.04, i32 1</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  br i1 %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">tobool</span><span style="font-variant-ligatures:no-common-ligatures">, label %while.end, label %while.body</span></div><div><br></div></div></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">LLVM 9 uses “llvm.uadd”. This finally prevents the “Hexagon Hardware Loops” pass to recognise a hardware loop pattern, resulting in sub-optimal code, specially compared with what LLVM 7.0 produces.</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">The code (excerpt) just before the Hexagon Hardware Loops pass on LLVM 9 is this:</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span><span style="font-variant-ligatures:no-common-ligatures">:</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">; predecessors: %bb.1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  successors: %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">(0x80000000); %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">100.00</span><span style="font-variant-ligatures:no-common-ligatures">%)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">8</span><span style="font-variant-ligatures:no-common-ligatures">:intregs = A2_tfrsi -100</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  J2_jump %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">, implicit-def $pc</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></div><div style="font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">.while.body:</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">; predecessors: %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  successors: %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">(0x04000000), %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">(0x7c000000); %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">(3.12%), %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">(96.88%)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %0:intregs = PHI %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">8</span><span style="font-variant-ligatures:no-common-ligatures">:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span><span style="font-variant-ligatures:no-common-ligatures">, %3:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %1:intregs = PHI %7:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span><span style="font-variant-ligatures:no-common-ligatures">, %5:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %2:intregs = PHI %6:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span><span style="font-variant-ligatures:no-common-ligatures">, %4:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">13</span><span style="font-variant-ligatures:no-common-ligatures">:intregs, %4:intregs = L2_loadri_pi %2:intregs</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">(tied-def 1)</span><span style="font-variant-ligatures:no-common-ligatures">, 4 :: (load 4 from %ir.a.addr.03, !tbaa !2)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %5:intregs = S2_storeri_pi %1:intregs</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">(tied-def 0)</span><span style="font-variant-ligatures:no-common-ligatures">, 4, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">13</span><span style="font-variant-ligatures:no-common-ligatures">:intregs :: (store 4 into %ir.res.addr.04, !tbaa !2)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %3:intregs = A2_addi %0:intregs, 1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">14</span><span style="font-variant-ligatures:no-common-ligatures">:predregs = </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">C2_cmpgtu</span><span style="font-variant-ligatures:no-common-ligatures"> %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">0</span><span style="font-variant-ligatures:no-common-ligatures">:intregs, </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">%3:intregs</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  J2_jumpf %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">14</span><span style="font-variant-ligatures:no-common-ligatures">:predregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">, implicit-def dead $pc</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  J2_jump %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">, implicit-def dead $pc</span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">The same code on LLVM 7 is this:</div><div style="font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">2.while.body.preheader</span><span style="font-variant-ligatures:no-common-ligatures">:</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">; predecessors: %bb.1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  successors: %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">(0x80000000); %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">200.00</span><span style="font-variant-ligatures:no-common-ligatures">%)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">11</span><span style="font-variant-ligatures:no-common-ligatures">:intregs = A2_tfrsi -100</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  J2_jump %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">, implicit-def </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">dead </span><span style="font-variant-ligatures:no-common-ligatures">$pc</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></div><div style="font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">.while.body:</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">; predecessors: %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">2</span><span style="font-variant-ligatures:no-common-ligatures">, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  successors: %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span><span style="font-variant-ligatures:no-common-ligatures">(0x04000000), %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">(0x7c000000); %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span><span style="font-variant-ligatures:no-common-ligatures">(3.12%), %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">(96.88%)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %0:intregs = PHI %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">11</span><span style="font-variant-ligatures:no-common-ligatures">:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">2</span><span style="font-variant-ligatures:no-common-ligatures">, %3:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %1:intregs = PHI %7:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">2</span><span style="font-variant-ligatures:no-common-ligatures">, %5:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %2:intregs = PHI %6:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">2</span><span style="font-variant-ligatures:no-common-ligatures">, %4:intregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">12</span><span style="font-variant-ligatures:no-common-ligatures">:intregs, %4:intregs = L2_loadri_pi %2:intregs, 4 :: (load 4 from %ir.a.addr.03, !tbaa !2)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %5:intregs = S2_storeri_pi %1:intregs, 4, %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">12</span><span style="font-variant-ligatures:no-common-ligatures">:intregs :: (store 4 into %ir.res.addr.04, !tbaa !2)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %3:intregs = A2_addi %0:intregs, 1</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">13</span><span style="font-variant-ligatures:no-common-ligatures">:predregs = </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">C2_cmpeqi</span><span style="font-variant-ligatures:no-common-ligatures"> %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">3</span><span style="font-variant-ligatures:no-common-ligatures">:intregs, </span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">0</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  J2_jumpf %</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">13</span><span style="font-variant-ligatures:no-common-ligatures">:predregs, %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">4</span><span style="font-variant-ligatures:no-common-ligatures">, implicit-def dead $pc</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">  J2_jump %bb.</span><span style="font-variant-ligatures:no-common-ligatures;background-color:rgb(212,237,244)">5</span><span style="font-variant-ligatures:no-common-ligatures">, implicit-def dead $pc</span></div></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">The differences above allow LLVM 7 to turn %13, %3, %11 into a hardware Loop as shown in the assembly code earlier in this message. However, LLVM 9 can’t identify a Hardware loop pattern due to the odd C2_cmpgtu instruction that gets generated. This instruction is a consequence of the introduction of the “llvm.addu” intrinsic that I showed earlier.</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">I am presenting here the case of Hexagon, but I suspect the same sub-optimal code may happen for the PowerPC (not checked yet).</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">All the code excerpts were obtained with -Os flags</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">I’m highly interested in getting in contact with someone familiar with the Hexagon/PowerPC targets regarding this subject. Any pointers to the right persons would be appreciated. My interest comes from the fact that I am proposing an improvement on the LSR pass that affects all targets and I need hardware loops to be properly generated in LLVM 9 like they used to be in LLVM 7. </div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">Thanks</div><div style="font-family:Helvetica;font-size:12px"><br></div><div style="font-family:Helvetica;font-size:12px">John.</div><div><br></div><div><br></div><div><br></div></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>