<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 25, 2019, at 08:31, Joan Lluch via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi All,<div class=""><br class=""></div><div class="">This simple loop code</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">void</span> loopTest()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class="">{</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class="">  <span style="color: #ba2da2" class="">for</span> ( <span style="color: #ba2da2" class="">int</span> i = <span style="color: #272ad8" class="">0</span> ; i<<span style="color: #272ad8" class="">10</span> ; i++ ) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class="">    ftest();</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class="">  }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class="">}</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">gets converted into this when compiled with the -Os flags:</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Monaco; background-color: rgb(255, 255, 255);" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255);" class=""><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class="">; Function Attrs: nounwind optsize uwtable</div><div style="margin: 0px; line-height: normal;" class="">define void @loopTest() local_unnamed_addr #0 {</div><div style="margin: 0px; line-height: normal;" class="">entry:</div><div style="margin: 0px; line-height: normal;" class="">  br label %for.body</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">for.cond.cleanup:                                 ; preds = %for.body</div><div style="margin: 0px; line-height: normal;" class="">  ret void</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">for.body:                                         ; preds = %for.body, %entry</div><div style="margin: 0px; line-height: normal;" class="">  %i.03 = phi i32 [ 0, %entry ], [ %inc, %for.body ]</div><div style="margin: 0px; line-height: normal;" class="">  %call = tail call i32 (...) @ftest() #2</div><div style="margin: 0px; line-height: normal;" class="">  %inc = add nuw nsw i32 %i.03, 1</div><div style="margin: 0px; line-height: normal;" class="">  %exitcond = icmp eq i32 %inc, 10</div><div style="margin: 0px; line-height: normal;" class="">  br i1 %exitcond, label %for.cond.cleanup, label %for.body</div><div style="margin: 0px; line-height: normal;" class="">}</div></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">For the x86 architecture, this gets compiled into this</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>.section<span class="Apple-tab-span" style="white-space:pre">    </span>__TEXT,__text,regular,pure_instructions</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.macosx_version_min <span style="color: #272ad8" class="">10</span>, <span style="color: #272ad8" class="">12</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">    </span>.globl<span class="Apple-tab-span" style="white-space:pre">      </span>_loopTest               <span style="color: #008400" class="">## -- Begin function loopTest</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">_loopTest:                              <span style="color: #008400" class="">## @loopTest</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>.cfi_startproc</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">## %bb.0:                               ## %entry</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>pushq<span class="Apple-tab-span" style="white-space:pre">       </span>%rbp                    <span style="color: #008400" class="">## encoding: [0x55]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>.cfi_def_cfa_offset <span style="color: #272ad8" class="">16</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>.cfi_offset %rbp, <span style="color: #272ad8" class="">-16</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>movq<span class="Apple-tab-span" style="white-space:pre">        </span>%rsp, %rbp              <span style="color: #008400" class="">## encoding: [0x48,0x89,0xe5]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>.cfi_def_cfa_register %rbp</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>pushq<span class="Apple-tab-span" style="white-space:pre">       </span>%rbx                    <span style="color: #008400" class="">## encoding: [0x53]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>pushq<span class="Apple-tab-span" style="white-space:pre">       </span>%rax                    <span style="color: #008400" class="">## encoding: [0x50]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>.cfi_offset %rbx, <span style="color: #272ad8" class="">-24</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>movl<span class="Apple-tab-span" style="white-space:pre">        </span>$</span><span style="color: #272ad8" class="">10</span><span style="" class="">, %ebx               </span>## encoding: [0xbb,0x0a,0x00,0x00,0x00]</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">LBB0_<span style="color: #272ad8" class="">1</span>:                                 <span style="color: #008400" class="">## %for.body</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">                                        <span style="color: #008400" class="">## =>This Inner Loop Header: Depth=1</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>xorl<span class="Apple-tab-span" style="white-space:pre">        </span>%eax, %eax              <span style="color: #008400" class="">## encoding: [0x31,0xc0]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>callq<span class="Apple-tab-span" style="white-space:pre">       </span>_ftest                  <span style="color: #008400" class="">## encoding: [0xe8,A,A,A,A]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">                                        </span>##   fixup A - offset: 1, value: _ftest-4, kind: reloc_branch_4byte_pcrel</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>decl<span class="Apple-tab-span" style="white-space:pre">        </span>%ebx                    <span style="color: #008400" class="">## encoding: [0xff,0xcb]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>jne<span class="Apple-tab-span" style="white-space:pre"> </span>LBB0_<span style="color: #272ad8" class="">1</span>                  <span style="color: #008400" class="">## encoding: [0x75,A]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">                                        </span>##   fixup A - offset: 1, value: LBB0_1-1, kind: FK_PCRel_1</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">## %bb.2:                               ## %for.cond.cleanup</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>addq<span class="Apple-tab-span" style="white-space:pre">        </span>$</span><span style="color: #272ad8" class="">8</span><span style="" class="">, %rsp                </span>## encoding: [0x48,0x83,0xc4,0x08]</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>popq<span class="Apple-tab-span" style="white-space:pre">        </span>%rbx                    <span style="color: #008400" class="">## encoding: [0x5b]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>popq<span class="Apple-tab-span" style="white-space:pre">        </span>%rbp                    <span style="color: #008400" class="">## encoding: [0x5d]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>retq                            <span style="color: #008400" class="">## encoding: [0xc3]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>.cfi_endproc</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">                                        <span style="color: #008400" class="">## -- End function</span></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">The same code compiled with -Oz results in the following:</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class="">; Function Attrs: minsize nounwind optsize uwtable</div><div style="margin: 0px; line-height: normal;" class="">define void @loopTest() local_unnamed_addr #0 {</div><div style="margin: 0px; line-height: normal;" class="">entry:</div><div style="margin: 0px; line-height: normal;" class="">  br label %for.cond</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">for.cond:                                         ; preds = %for.body, %entry</div><div style="margin: 0px; line-height: normal;" class="">  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]</div><div style="margin: 0px; line-height: normal;" class="">  %exitcond = icmp eq i32 %i.0, 10</div><div style="margin: 0px; line-height: normal;" class="">  br i1 %exitcond, label %for.cond.cleanup, label %for.body</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">for.cond.cleanup:                                 ; preds = %for.cond</div><div style="margin: 0px; line-height: normal;" class="">  ret void</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Helvetica; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">for.body:                                         ; preds = %for.cond</div><div style="margin: 0px; line-height: normal;" class="">  %call = tail call i32 (...) @ftest() #2</div><div style="margin: 0px; line-height: normal;" class="">  %inc = add nuw nsw i32 %i.0, 1</div><div style="margin: 0px; line-height: normal;" class="">  br label %for.cond</div><div style="margin: 0px; line-height: normal;" class="">}</div></div></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">and this</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.section<span class="Apple-tab-span" style="white-space:pre">    </span>__TEXT,__text,regular,pure_instructions</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>.macosx_version_min <span style="color: #272ad8" class="">10</span>, <span style="color: #272ad8" class="">12</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">    </span>.globl<span class="Apple-tab-span" style="white-space:pre">      </span>_loopTest               <span style="color: #008400" class="">## -- Begin function loopTest</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">_loopTest:                              <span style="color: #008400" class="">## @loopTest</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>.cfi_startproc</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">## %bb.0:                               ## %entry</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>pushq<span class="Apple-tab-span" style="white-space:pre">       </span>%rbp                    <span style="color: #008400" class="">## encoding: [0x55]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>.cfi_def_cfa_offset <span style="color: #272ad8" class="">16</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>.cfi_offset %rbp, <span style="color: #272ad8" class="">-16</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>movq<span class="Apple-tab-span" style="white-space:pre">        </span>%rsp, %rbp              <span style="color: #008400" class="">## encoding: [0x48,0x89,0xe5]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>.cfi_def_cfa_register %rbp</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>pushq<span class="Apple-tab-span" style="white-space:pre">       </span>%rbx                    <span style="color: #008400" class="">## encoding: [0x53]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>pushq<span class="Apple-tab-span" style="white-space:pre">       </span>%rax                    <span style="color: #008400" class="">## encoding: [0x50]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>.cfi_offset %rbx, <span style="color: #272ad8" class="">-24</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>pushq<span class="Apple-tab-span" style="white-space:pre">       </span>$<span style="color: #272ad8" class="">10</span>                     <span style="color: #008400" class="">## encoding: [0x6a,0x0a]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">    </span>popq<span class="Apple-tab-span" style="white-space:pre">        </span>%rbx                    <span style="color: #008400" class="">## encoding: [0x5b]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">LBB0_<span style="color: #272ad8" class="">1</span>:                                 <span style="color: #008400" class="">## %for.cond</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">                                        <span style="color: #008400" class="">## =>This Inner Loop Header: Depth=1</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>testl<span class="Apple-tab-span" style="white-space:pre">       </span>%ebx, %ebx              <span style="color: #008400" class="">## encoding: [0x85,0xdb]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>je<span class="Apple-tab-span" style="white-space:pre">  </span>LBB0_<span style="color: #272ad8" class="">2</span>                  <span style="color: #008400" class="">## encoding: [0x74,A]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">                                        </span>##   fixup A - offset: 1, value: LBB0_2-1, kind: FK_PCRel_1</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class="">## %bb.3:                               ## %for.body</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">                                        <span style="color: #008400" class="">##   in Loop: Header=BB0_1 Depth=1</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>xorl<span class="Apple-tab-span" style="white-space:pre">        </span>%eax, %eax              <span style="color: #008400" class="">## encoding: [0x31,0xc0]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>callq<span class="Apple-tab-span" style="white-space:pre">       </span>_ftest                  <span style="color: #008400" class="">## encoding: [0xe8,A,A,A,A]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">                                        </span>##   fixup A - offset: 1, value: _ftest-4, kind: reloc_branch_4byte_pcrel</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>decl<span class="Apple-tab-span" style="white-space:pre">        </span>%ebx                    <span style="color: #008400" class="">## encoding: [0xff,0xcb]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>jmp<span class="Apple-tab-span" style="white-space:pre"> </span>LBB0_<span style="color: #272ad8" class="">1</span>                  <span style="color: #008400" class="">## encoding: [0xeb,A]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">                                        </span>##   fixup A - offset: 1, value: LBB0_1-1, kind: FK_PCRel_1</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">LBB0_<span style="color: #272ad8" class="">2</span>:                                 <span style="color: #008400" class="">## %for.cond.cleanup</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>addq<span class="Apple-tab-span" style="white-space:pre">        </span>$</span><span style="color: #272ad8" class="">8</span><span style="" class="">, %rsp                </span>## encoding: [0x48,0x83,0xc4,0x08]</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>popq<span class="Apple-tab-span" style="white-space:pre">        </span>%rbx                    <span style="color: #008400" class="">## encoding: [0x5b]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>popq<span class="Apple-tab-span" style="white-space:pre">        </span>%rbp                    <span style="color: #008400" class="">## encoding: [0x5d]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>retq                            <span style="color: #008400" class="">## encoding: [0xc3]</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>.cfi_endproc</div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class="">                                        <span style="color: #008400" class="">## -- End function</span></div><div style="font-family: Helvetica; font-size: 12px; margin: 0px; line-height: normal; min-height: 14px;" class=""><br class=""></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">The resulting loop body code for -Oz is longer than -Os. This is because the exit loop comparison is performed at the beginning of the loop resulting in an additional jump instruction and missing opportunity to fold the exit condition with the iv decrement.</span></div><div style="font-family: Monaco; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-family: Helvetica; font-size: 12px;" class=""><br class=""></span></div></div></div></div></div></div></div></blockquote><div><br class=""></div><div>The problem here is that with -Oz, LoopRotate is *very* conservative. Currently it is not clever enough to realize that the  loop guard would always be true.</div><div><br class=""></div><div>I’ve a patch that fixes that <a href="https://reviews.llvm.org/D61683" class="">https://reviews.llvm.org/D61683</a>. There were some code-size improvements, as well as regressions. I just need to find some time to look into the causes for the regressions.</div><div><br class=""></div><div><br class=""></div><div>Cheers,</div><div>Florian</div></div></body></html>