<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:Monaco;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Menlo;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.apple-tab-span
        {mso-style-name:apple-tab-span;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">The Hexagon part is fixed in r364790.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:Consolas">-- </span>
<span style="font-size:9.0pt;font-family:Consolas"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:8.0pt;font-family:Consolas">Krzysztof Parzyszek 
<a href="mailto:kparzysz@quicinc.com"><span style="color:#0563C1">kparzysz@quicinc.com</span></a>   LLVM compiler development<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> <b>On Behalf Of
</b>Joan Lluch via llvm-dev<br>
<b>Sent:</b> Sunday, June 30, 2019 2:04 PM<br>
<b>To:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [EXT] [llvm-dev] [hexagon][PowerPC] code regression (sub-optimal code) on LLVM 9 when generating hardware loops, and the "llvm.uadd" intrinsic.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi All,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The following code :<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#BA2DA2">void</span><span style="font-size:8.5pt;font-family:"Monaco",serif"> hexagon2(
<span style="color:#BA2DA2">int</span> *a, <span style="color:#BA2DA2">int</span> *res )<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"> 
<span style="color:#BA2DA2">int</span> i = <span style="color:#272AD8">100</span>; <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"> 
<span style="color:#BA2DA2">while</span> ( i-- ) {<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">    *res++ = *a++;<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">  }<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">}<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This is the final assembly code generated by LLVM 9.0 :<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.text<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">.file<span class="apple-tab-span">               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#D12F1B">"main.c"<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.globl<span class="apple-tab-span">           
</span>hexagon2                <span style="color:#008400">// -- Begin function hexagon2</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.p2align<span class="apple-tab-span">     
</span><span style="color:#272AD8">2</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.type<span class="apple-tab-span">            
</span>hexagon2,@function<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">hexagon2:                              
<span style="color:#008400">// @hexagon2</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.0:                               // %entry.old<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">p0 = cmp.gtu(r0,r1); if (p0.new) jump:nt .LBB0_<span style="color:#272AD8">5</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r2 = r0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">allocframe(<span style="color:#008400">#0)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [A,0x41'A',A,0x15'A',0x00,0x3c,0x02,0x70]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B9_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.1:                               // %entry.old<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r0 = sub(r1,r0)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x00,0xc1,0x20,0xf3]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">if (p0.new) jump:nt .LBB0_<span style="color:#272AD8">5</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">p0 = cmp.gt(r0,<span style="color:#008400">#399)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [A,0x48'A',A,0x5c'A',0xe0,0xf1,0x40,0x75]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B15_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.2:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r0 = <span style="color:#008400">
#-100</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x80,0xf3,0xdf,0x78]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">.LBB0_<span style="color:#272AD8">3</span>:                               
<span style="color:#008400">// %while.body</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                       
<span style="color:#008400">// =>This Inner Loop Header: Depth=1</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r3 = add(r0,<span style="color:#008400">#1)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r4 = memw(r2++<span style="color:#008400">#4)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">memw(r1++</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">#4) = r4.new<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x23,0x40,0x00,0xb0,0x24,0x40,0x82,0x9b,0x08,0xd2,0xa1,0xab]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">p0 = cmp.gtu(r0,r3); if (!p0.new) jump:t .LBB0_<span style="color:#272AD8">3</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r0 = r3<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [A,0x63'A',0x40'A',0x15'A',0x00,0xc0,0x63,0x70]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: .LBB0_3, kind: fixup_Hexagon_B9_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.4:                               // %while.end<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r31:<span style="color:#272AD8">30</span> = dealloc_return(r30):raw<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x1e,0xc0,0x1e,0x96]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">.LBB0_<span style="color:#272AD8">5</span>:                               
<span style="color:#008400">// %while.body.rtli</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">call memmove<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r1:<span style="color:#272AD8">0</span> = combine(r2,r1)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r2 = <span style="color:#008400">
#400</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [A,0x40'A',A,0x5a'A',0x00,0x41,0x02,0xf5,0x02,0xf2,0x00,0x78]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: memmove, kind: fixup_Hexagon_B22_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r31:<span style="color:#272AD8">30</span> = dealloc_return(r30):raw<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x1e,0xc0,0x1e,0x96]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">.Lfunc_end0:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.size<span class="apple-tab-span">             
</span>hexagon2, .Lfunc_end0-hexagon2<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                       
<span style="color:#008400">// -- End function</span><o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">This is the assembly code generated by LLVM 7.0 :</span><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.text<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">.file<span class="apple-tab-span">               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#D12F1B">"main.c"<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.globl<span class="apple-tab-span">           
</span>hexagon2                <span style="color:#008400">// -- Begin function hexagon2</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.p2align<span class="apple-tab-span">     
</span><span style="color:#272AD8">2</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.type<span class="apple-tab-span">            
</span>hexagon2,@function<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">hexagon2:                              
<span style="color:#008400">// @hexagon2</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.0:                               // %entry.old<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">p0 = cmp.gtu(r0,r1); if (p0.new) jump:nt .LBB0_<span style="color:#272AD8">5</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r2 = r0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">allocframe(<span style="color:#008400">#0)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [A,0x41'A',A,0x15'A',0x00,0x3c,0x02,0x70]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B9_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.1:                               // %entry.old<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r0 = sub(r1,r0)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x00,0xc1,0x20,0xf3]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">if (p0.new) jump:nt .LBB0_<span style="color:#272AD8">5</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">p0 = cmp.gt(r0,<span style="color:#008400">#399)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [A,0x48'A',A,0x5c'A',0xe0,0xf1,0x40,0x75]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: .LBB0_5, kind: fixup_Hexagon_B15_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.2:                               // %while.body.preheader<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">loop0(.LBB0_<span style="color:#272AD8">3</span>,<span style="color:#008400">#100)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x20'A',0xc0'A',0x03'A',0x69'A']<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: .LBB0_3, kind: fixup_Hexagon_B7_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">.Ltmp0:                                
<span style="color:#008400">// Block address taken</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">.LBB0_<span style="color:#272AD8">3</span>:                               
<span style="color:#008400">// %while.body</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                       
<span style="color:#008400">// =>This Inner Loop Header: Depth=1</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r0 = memw(r2++<span style="color:#008400">#4)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">memw(r1++</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">#4) = r0.new<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">} :endloop0                    
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x20,0x80,0x82,0x9b,0x08,0xd2,0xa1,0xab]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// %bb.4:                               // %while.end<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r31:<span style="color:#272AD8">30</span> = dealloc_return(r30):raw<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x1e,0xc0,0x1e,0x96]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">.LBB0_<span style="color:#272AD8">5</span>:                               
<span style="color:#008400">// %while.body.rtli</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">call memmove<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r1:<span style="color:#272AD8">0</span> = combine(r2,r1)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r2 = <span style="color:#008400">
#400</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [A,0x40'A',A,0x5a'A',0x00,0x41,0x02,0xf5,0x02,0xf2,0x00,0x78]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                                       
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">//   fixup A - offset: 0, value: memmove, kind: fixup_Hexagon_B22_PCREL<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">{<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                               
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">r31:<span style="color:#272AD8">30</span> = dealloc_return(r30):raw<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:black">}                              
</span><span style="font-size:8.5pt;font-family:"Monaco",serif;color:#008400">// encoding: [0x1e,0xc0,0x1e,0x96]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">.Lfunc_end0:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span class="apple-tab-span"><span style="font-size:8.5pt;font-family:"Monaco",serif">                       
</span></span><span style="font-size:8.5pt;font-family:"Monaco",serif">.size<span class="apple-tab-span">             
</span>hexagon2, .Lfunc_end0-hexagon2<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif">                                       
<span style="color:#008400">// -- End function</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">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.<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">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. <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">This is the while.body excerpt after "CodeGen Prepare” in LLVM 9.0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">while.body:                                       ; preds = %<span style="background:#D4EDF4">entry.old</span>, %while.body<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %lsr.iv = phi i32 [
<span style="background:#D4EDF4">%math</span>, %<span style="background:#D4EDF4">while.body</span> ], [
<span style="background:#D4EDF4">-100</span>, %<span style="background:#D4EDF4">entry.old</span> ]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %res.addr.04 = phi i32* [ %cgep1, %while.body ], [ %res, %<span style="background:#D4EDF4">entry.old</span> ]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %a.addr.03 = phi i32* [ %cgep, %while.body ], [ %a, %<span style="background:#D4EDF4">entry.old</span> ]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %6 = load i32, i32* %a.addr.03, align 4, !tbaa !2<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  store i32 %6, i32* %res.addr.04, align 4, !tbaa !2<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">7</span> =
<span style="background:#D4EDF4">call</span> <span style="background:#D4EDF4">{</span> i32<span style="background:#D4EDF4">,</span>
<span style="background:#D4EDF4">i1 } @llvm.uadd.with.overflow.i32(i32 </span>%lsr.iv,
<span style="background:#D4EDF4">i32 </span>1<span style="background:#D4EDF4">)</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">math</span> =
<span style="background:#D4EDF4">extractvalue</span> <span style="background:#D4EDF4">
{</span> i32<span style="background:#D4EDF4">,</span> <span style="background:#D4EDF4">
i1 } </span>%<span style="background:#D4EDF4">7</span>, 0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:#D4EDF4"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %ov = extractvalue { i32, i1 } %7, 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %cgep = getelementptr inbounds i32, i32* %a.addr.03, i32 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %cgep1 = getelementptr inbounds i32, i32* %res.addr.04, i32 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  br i1 %<span style="background:#D4EDF4">ov</span>, label %while.end, label %while.body<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">And this is the same excerpt on  LLVM 7.0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">while.body:                                       ; preds = %<span style="background:#D4EDF4">while.body.preheader</span>, %while.body<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %lsr.iv = phi i32 [
<span style="background:#D4EDF4">-100</span>, %<span style="background:#D4EDF4">while.body.preheader</span> ], [
<span style="background:#D4EDF4">%lsr.iv.next</span>, %<span style="background:#D4EDF4">while.body</span> ]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %res.addr.04 = phi i32* [ %cgep1, %while.body ], [ %res, %<span style="background:#D4EDF4">while.body.preheader</span> ]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %a.addr.03 = phi i32* [ %cgep, %while.body ], [ %a, %<span style="background:#D4EDF4">while.body.preheader</span> ]<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %6 = load i32, i32* %a.addr.03, align 4, !tbaa !2<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  store i32 %6, i32* %res.addr.04, align 4, !tbaa !2<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">lsr.iv.next</span> =
<span style="background:#D4EDF4">add</span> <span style="background:#D4EDF4">nsw</span> i32 %lsr.iv, 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">tobool</span> =
<span style="background:#D4EDF4">icmp</span> <span style="background:#D4EDF4">eq</span> i32 %<span style="background:#D4EDF4">lsr.iv.next</span>, 0<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %cgep = getelementptr inbounds i32, i32* %a.addr.03, i32 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %cgep1 = getelementptr inbounds i32, i32* %res.addr.04, i32 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  br i1 %<span style="background:#D4EDF4">tobool</span>, label %while.end, label %while.body<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><o:p> </o:p></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">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.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">The code (excerpt) just before the Hexagon Hardware Loops pass on LLVM 9 is this:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">bb.<span style="background:#D4EDF4">5</span>:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">; predecessors: %bb.1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  successors: %bb.<span style="background:#D4EDF4">3</span>(0x80000000); %bb.<span style="background:#D4EDF4">3</span>(<span style="background:#D4EDF4">100.00</span>%)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">8</span>:intregs = A2_tfrsi -100<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  J2_jump %bb.<span style="background:#D4EDF4">3</span>, implicit-def $pc<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><br>
<br>
<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">bb.<span style="background:#D4EDF4">3</span>.while.body:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">; predecessors: %bb.<span style="background:#D4EDF4">3</span>, %bb.<span style="background:#D4EDF4">5</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  successors: %bb.<span style="background:#D4EDF4">4</span>(0x04000000), %bb.<span style="background:#D4EDF4">3</span>(0x7c000000); %bb.<span style="background:#D4EDF4">4</span>(3.12%),
 %bb.<span style="background:#D4EDF4">3</span>(96.88%)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %0:intregs = PHI %<span style="background:#D4EDF4">8</span>:intregs, %bb.<span style="background:#D4EDF4">5</span>, %3:intregs, %bb.<span style="background:#D4EDF4">3</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %1:intregs = PHI %7:intregs, %bb.<span style="background:#D4EDF4">5</span>, %5:intregs, %bb.<span style="background:#D4EDF4">3</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %2:intregs = PHI %6:intregs, %bb.<span style="background:#D4EDF4">5</span>, %4:intregs, %bb.<span style="background:#D4EDF4">3</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">13</span>:intregs, %4:intregs = L2_loadri_pi %2:intregs<span style="background:#D4EDF4">(tied-def 1)</span>, 4 :: (load
 4 from %ir.a.addr.03, !tbaa !2)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %5:intregs = S2_storeri_pi %1:intregs<span style="background:#D4EDF4">(tied-def 0)</span>, 4, %<span style="background:#D4EDF4">13</span>:intregs :: (store
 4 into %ir.res.addr.04, !tbaa !2)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %3:intregs = A2_addi %0:intregs, 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">14</span>:predregs =
<span style="background:#D4EDF4">C2_cmpgtu</span> %<span style="background:#D4EDF4">0</span>:intregs,
<span style="background:#D4EDF4">%3:intregs</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  J2_jumpf %<span style="background:#D4EDF4">14</span>:predregs, %bb.<span style="background:#D4EDF4">3</span>, implicit-def dead $pc<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  J2_jump %bb.<span style="background:#D4EDF4">4</span>, implicit-def dead $pc<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><br>
<br>
<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">The same code on LLVM 7 is this:<o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><br>
<br>
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">bb.<span style="background:#D4EDF4">2.while.body.preheader</span>:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">; predecessors: %bb.1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  successors: %bb.<span style="background:#D4EDF4">4</span>(0x80000000); %bb.<span style="background:#D4EDF4">4</span>(<span style="background:#D4EDF4">200.00</span>%)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">11</span>:intregs = A2_tfrsi -100<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  J2_jump %bb.<span style="background:#D4EDF4">4</span>, implicit-def
<span style="background:#D4EDF4">dead </span>$pc<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><br>
<br>
<o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">bb.<span style="background:#D4EDF4">4</span>.while.body:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">; predecessors: %bb.<span style="background:#D4EDF4">2</span>, %bb.<span style="background:#D4EDF4">4</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  successors: %bb.<span style="background:#D4EDF4">5</span>(0x04000000), %bb.<span style="background:#D4EDF4">4</span>(0x7c000000); %bb.<span style="background:#D4EDF4">5</span>(3.12%),
 %bb.<span style="background:#D4EDF4">4</span>(96.88%)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %0:intregs = PHI %<span style="background:#D4EDF4">11</span>:intregs, %bb.<span style="background:#D4EDF4">2</span>, %3:intregs, %bb.<span style="background:#D4EDF4">4</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %1:intregs = PHI %7:intregs, %bb.<span style="background:#D4EDF4">2</span>, %5:intregs, %bb.<span style="background:#D4EDF4">4</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %2:intregs = PHI %6:intregs, %bb.<span style="background:#D4EDF4">2</span>, %4:intregs, %bb.<span style="background:#D4EDF4">4</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">12</span>:intregs, %4:intregs = L2_loadri_pi %2:intregs, 4 :: (load 4 from %ir.a.addr.03, !tbaa !2)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %5:intregs = S2_storeri_pi %1:intregs, 4, %<span style="background:#D4EDF4">12</span>:intregs :: (store 4 into %ir.res.addr.04, !tbaa !2)<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %3:intregs = A2_addi %0:intregs, 1<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  %<span style="background:#D4EDF4">13</span>:predregs =
<span style="background:#D4EDF4">C2_cmpeqi</span> %<span style="background:#D4EDF4">3</span>:intregs,
<span style="background:#D4EDF4">0</span><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  J2_jumpf %<span style="background:#D4EDF4">13</span>:predregs, %bb.<span style="background:#D4EDF4">4</span>, implicit-def dead $pc<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Menlo",serif">  J2_jump %bb.<span style="background:#D4EDF4">5</span>, implicit-def dead $pc<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">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.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">I am presenting here the case of Hexagon, but I suspect the same sub-optimal code may happen for the PowerPC (not checked yet).<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">All the code excerpts were obtained with -Os flags<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">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. <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Thanks<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">John.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="background:white"><span style="font-size:8.5pt;font-family:"Monaco",serif"><o:p> </o:p></span></p>
</div>
</div>
</div>
</body>
</html>