<!DOCTYPE html>
<html lang="vi" data-theme="auto">
<head>

<link rel="preconnect" href="https://www.googletagmanager.com">
<script >(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','GTM-W8MVQXG');</script>
  
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#00add8">
<link rel="canonical" href="https://go.dev/src/internal/bytealg/index_ppc64x.s">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons">
<link rel="stylesheet" href="/css/styles.css">
<link rel="icon" href="/images/favicon-gopher.png" sizes="any">
<link rel="apple-touch-icon" href="/images/favicon-gopher-plain.png"/>
<link rel="icon" href="/images/favicon-gopher.svg" type="image/svg+xml">
<link rel="me" href="https://hachyderm.io/@golang">

  
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','GTM-W8MVQXG');</script>
  
<script src="/js/site.js"></script>
<meta name="og:url" content="https://go.dev/src/internal/bytealg/index_ppc64x.s">
<meta name="og:title" content=" - The Go Programming Language">
<title> - The Go Programming Language</title>

<meta name="og:image" content="https://go.dev/doc/gopher/gopher5logo.jpg">
<meta name="twitter:image" content="https://go.dev/doc/gopher/gopherbelly300.jpg">
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@golang">
</head>
<body class="Site">
  
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W8MVQXG"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  


<header class="Site-header js-siteHeader">
  <div class="Header Header--dark">
    <nav class="Header-nav">
      <a href="/">
        <img
          class="js-headerLogo Header-logo"
          src="/images/go-logo-white.svg"
          alt="Go">
      </a>
      <div class="skip-navigation-wrapper">
        <a class="skip-to-content-link" aria-label="Bỏ qua để đến nội dung chính" href="#main-content"> Bỏ qua đến nội dung chính </a>
      </div>
      <div class="Header-rightContent">
        <ul class="Header-menu">
          <li class="Header-menuItem ">
            <a href="#"  class="js-desktop-menu-hover" aria-label=Tại&#32;sao&#32;Go aria-describedby="dropdown-description">
              Tại sao Go <i class="material-icons" aria-hidden="true">arrow_drop_down</i>
            </a>
            <div class="screen-reader-only" id="dropdown-description" hidden>
              Nhấn Enter để bật/tắt menu thả xuống
            </div>
              <ul class="Header-submenu js-desktop-submenu-hover" aria-label="submenu">
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/solutions/case-studies">
                          Case Studies
                          
                        </a>
                    </div>
                    <p>Các vấn đề phổ biến mà doanh nghiệp giải quyết bằng Go</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/solutions/use-cases">
                          Use Cases
                          
                        </a>
                    </div>
                    <p>Câu chuyện về cách thức và lý do các công ty sử dụng Go</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/security/">
                          Bảo mật
                          
                        </a>
                    </div>
                    <p>Go giúp bạn bảo mật theo mặc định như thế nào</p>
                  </li>
              </ul>
          </li>
          <li class="Header-menuItem ">
            <a href="/learn/"  aria-label=Học aria-describedby="dropdown-description">
              Học 
            </a>
            <div class="screen-reader-only" id="dropdown-description" hidden>
              Nhấn Enter để bật/tắt menu thả xuống
            </div>
          </li>
          <li class="Header-menuItem ">
            <a href="#"  class="js-desktop-menu-hover" aria-label=Tài&#32;liệu aria-describedby="dropdown-description">
              Tài liệu <i class="material-icons" aria-hidden="true">arrow_drop_down</i>
            </a>
            <div class="screen-reader-only" id="dropdown-description" hidden>
              Nhấn Enter để bật/tắt menu thả xuống
            </div>
              <ul class="Header-submenu js-desktop-submenu-hover" aria-label="submenu">
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/ref/spec">
                          Go Spec
                          
                        </a>
                    </div>
                    <p>Đặc tả ngôn ngữ Go chính thức</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/doc">
                          Hướng dẫn sử dụng Go
                          
                        </a>
                    </div>
                    <p>Giới thiệu đầy đủ về cách xây dựng phần mềm với Go</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="https://pkg.go.dev/std">
                          Thư viện chuẩn
                          
                        </a>
                    </div>
                    <p>Tài liệu tham chiếu cho thư viện chuẩn của Go</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/doc/devel/release">
                          Ghi chú bản phát hành
                          
                        </a>
                    </div>
                    <p>Tìm hiểu những điểm mới trong từng bản phát hành Go</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/doc/effective_go">
                          Effective Go
                          
                        </a>
                    </div>
                    <p>Mẹo viết code Go rõ ràng, hiệu quả và đúng phong cách</p>
                  </li>
              </ul>
          </li>
          <li class="Header-menuItem ">
            <a href="https://pkg.go.dev"  aria-label=Packages aria-describedby="dropdown-description">
              Packages 
            </a>
            <div class="screen-reader-only" id="dropdown-description" hidden>
              Nhấn Enter để bật/tắt menu thả xuống
            </div>
          </li>
          <li class="Header-menuItem ">
            <a href="#"  class="js-desktop-menu-hover" aria-label=Cộng&#32;đồng aria-describedby="dropdown-description">
              Cộng đồng <i class="material-icons" aria-hidden="true">arrow_drop_down</i>
            </a>
            <div class="screen-reader-only" id="dropdown-description" hidden>
              Nhấn Enter để bật/tắt menu thả xuống
            </div>
              <ul class="Header-submenu js-desktop-submenu-hover" aria-label="submenu">
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/talks/">
                          Recorded Talks
                          
                        </a>
                    </div>
                    <p>Video từ các sự kiện trước đây</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="https://www.meetup.com/pro/go">
                          Meetups
                           <i class="material-icons">open_in_new</i>
                        </a>
                    </div>
                    <p>Gặp gỡ các lập trình viên Go địa phương khác</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/wiki/Conferences">
                          Hội nghị
                           <i class="material-icons">open_in_new</i>
                        </a>
                    </div>
                    <p>Học hỏi và kết nối với các lập trình viên Go trên toàn thế giới</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/blog">
                          Go blog
                          
                        </a>
                    </div>
                    <p>Blog chính thức của dự án Go.</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        <a href="/help">
                          Dự án Go
                          
                        </a>
                    </div>
                    <p>Nhận trợ giúp và cập nhật thông tin từ Go</p>
                  </li>
                  <li class="Header-submenuItem">
                    <div>
                        Kết nối
                    </div>
                    <p></p>
                      <div class="Header-socialIcons">
                        
                        <a class="Header-socialIcon" aria-label="Kết nối qua google-groups (Mở trong cửa sổ mới)" href="https://groups.google.com/g/golang-nuts"><img src="/images/logos/social/google-groups.svg" /></a>
                        <a class="Header-socialIcon" aria-label="Kết nối qua github (Mở trong cửa sổ mới)" href="https://github.com/golang"><img src="/images/logos/social/github.svg" /></a>
                        <a class="Header-socialIcon" aria-label="Kết nối qua bluesky (Mở trong cửa sổ mới)" href="https://bsky.app/profile/golang.org"><img src="/images/logos/social/bluesky.svg" /></a>
                        <a class="Header-socialIcon" aria-label="Kết nối qua mastodon (Mở trong cửa sổ mới)" href="https://hachyderm.io/@golang"><img src="/images/logos/social/mastodon.svg" /></a>
                        <a class="Header-socialIcon" aria-label="Kết nối qua twitter (Mở trong cửa sổ mới)" href="https://twitter.com/golang"><img src="/images/logos/social/twitter.svg" /></a>
                        <a class="Header-socialIcon" aria-label="Kết nối qua reddit (Mở trong cửa sổ mới)" href="https://www.reddit.com/r/golang/"><img src="/images/logos/social/reddit.svg" /></a>
                        <a class="Header-socialIcon" aria-label="Kết nối qua slack (Mở trong cửa sổ mới)" href="https://invite.slack.golangbridge.org/"><img src="/images/logos/social/slack.svg" /></a>
                        <a class="Header-socialIcon" aria-label="Kết nối qua stack-overflow (Mở trong cửa sổ mới)" href="https://stackoverflow.com/tags/go"><img src="/images/logos/social/stack-overflow.svg" /></a>
                      </div>
                  </li>
              </ul>
          </li>
        </ul>
        <button class="Header-navOpen js-headerMenuButton Header-navOpen--white" aria-label="Mở điều hướng.">
        </button>
      </div>
    </nav>
    
  </div>
</header>
<aside class="NavigationDrawer js-header">
  <nav class="NavigationDrawer-nav">
    <div class="NavigationDrawer-header">
      <a href="/">
        <img class="NavigationDrawer-logo" src="/images/go-logo-blue.svg" alt="Go.">
      </a>
    </div>
    <ul class="NavigationDrawer-list">
        
          <li class="NavigationDrawer-listItem js-mobile-subnav-trigger  NavigationDrawer-hasSubnav">
            <a href="#"><span>Tại sao Go</span> <i class="material-icons">navigate_next</i></a>

            <div class="NavigationDrawer NavigationDrawer-submenuItem">
              <nav class="NavigationDrawer-nav">
                <div class="NavigationDrawer-header">
                  <a href="#"><i class="material-icons">navigate_before</i>Tại sao Go</a>
                </div>
                <ul class="NavigationDrawer-list">
                    <li class="NavigationDrawer-listItem">
                        <a href="/solutions/case-studies">
                          Case Studies
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/solutions/use-cases">
                          Use Cases
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/security/">
                          Bảo mật
                          
                        </a>
                      
                    </li>
                </ul>
              </div>
            </div>
          </li>

        
        
          <li class="NavigationDrawer-listItem ">
            <a href="/learn/">Học</a>
          </li>
        
        
          <li class="NavigationDrawer-listItem js-mobile-subnav-trigger  NavigationDrawer-hasSubnav">
            <a href="#"><span>Tài liệu</span> <i class="material-icons">navigate_next</i></a>

            <div class="NavigationDrawer NavigationDrawer-submenuItem">
              <nav class="NavigationDrawer-nav">
                <div class="NavigationDrawer-header">
                  <a href="#"><i class="material-icons">navigate_before</i>Tài liệu</a>
                </div>
                <ul class="NavigationDrawer-list">
                    <li class="NavigationDrawer-listItem">
                        <a href="/ref/spec">
                          Go Spec
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/doc">
                          Hướng dẫn sử dụng Go
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="https://pkg.go.dev/std">
                          Thư viện chuẩn
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/doc/devel/release">
                          Ghi chú bản phát hành
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/doc/effective_go">
                          Effective Go
                          
                        </a>
                      
                    </li>
                </ul>
              </div>
            </div>
          </li>

        
        
          <li class="NavigationDrawer-listItem ">
            <a href="https://pkg.go.dev">Packages</a>
          </li>
        
        
          <li class="NavigationDrawer-listItem js-mobile-subnav-trigger  NavigationDrawer-hasSubnav">
            <a href="#"><span>Cộng đồng</span> <i class="material-icons">navigate_next</i></a>

            <div class="NavigationDrawer NavigationDrawer-submenuItem">
              <nav class="NavigationDrawer-nav">
                <div class="NavigationDrawer-header">
                  <a href="#"><i class="material-icons">navigate_before</i>Cộng đồng</a>
                </div>
                <ul class="NavigationDrawer-list">
                    <li class="NavigationDrawer-listItem">
                        <a href="/talks/">
                          Recorded Talks
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="https://www.meetup.com/pro/go">
                          Meetups
                           <i class="material-icons">open_in_new</i>
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/wiki/Conferences">
                          Hội nghị
                           <i class="material-icons">open_in_new</i>
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/blog">
                          Go blog
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <a href="/help">
                          Dự án Go
                          
                        </a>
                      
                    </li>
                    <li class="NavigationDrawer-listItem">
                        <div>Kết nối</div>
                        <div class="Header-socialIcons">
                          
                            <a class="Header-socialIcon" href="https://groups.google.com/g/golang-nuts"><img src="/images/logos/social/google-groups.svg" /></a>
                            <a class="Header-socialIcon" href="https://github.com/golang"><img src="/images/logos/social/github.svg" /></a>
                            <a class="Header-socialIcon" href="https://bsky.app/profile/golang.org"><img src="/images/logos/social/bluesky.svg" /></a>
                            <a class="Header-socialIcon" href="https://hachyderm.io/@golang"><img src="/images/logos/social/mastodon.svg" /></a>
                            <a class="Header-socialIcon" href="https://twitter.com/golang"><img src="/images/logos/social/twitter.svg" /></a>
                            <a class="Header-socialIcon" href="https://www.reddit.com/r/golang/"><img src="/images/logos/social/reddit.svg" /></a>
                            <a class="Header-socialIcon" href="https://invite.slack.golangbridge.org/"><img src="/images/logos/social/slack.svg" /></a>
                            <a class="Header-socialIcon" href="https://stackoverflow.com/tags/go"><img src="/images/logos/social/stack-overflow.svg" /></a>
                        </div>
                    </li>
                </ul>
              </div>
            </div>
          </li>

        
    </ul>
  </nav>
</aside>
<div class="NavigationDrawer-scrim js-scrim" role="presentation"></div>
<main class="SiteContent SiteContent--default" id="main-content">
  

<article class="Texthtml Article">


<h1>Tệp văn bản 


<a href="/src/">src</a>/<a href="/src/internal/">internal</a>/<a href="/src/internal/bytealg/">bytealg</a>/<span class="text-muted">index_ppc64x.s</span>
</h1>


<pre><span id="L1" class="ln">     1&nbsp;&nbsp;</span>// Copyright 2021 The Go Authors. All rights reserved.
<span id="L2" class="ln">     2&nbsp;&nbsp;</span>// Use of this source code is governed by a BSD-style
<span id="L3" class="ln">     3&nbsp;&nbsp;</span>// license that can be found in the LICENSE file.
<span id="L4" class="ln">     4&nbsp;&nbsp;</span>
<span id="L5" class="ln">     5&nbsp;&nbsp;</span>// This is an implementation based on the s390x
<span id="L6" class="ln">     6&nbsp;&nbsp;</span>// implementation.
<span id="L7" class="ln">     7&nbsp;&nbsp;</span>
<span id="L8" class="ln">     8&nbsp;&nbsp;</span>// Find a separator with 2 &lt;= len &lt;= 32 within a string.
<span id="L9" class="ln">     9&nbsp;&nbsp;</span>// Separators with lengths of 2, 3 or 4 are handled
<span id="L10" class="ln">    10&nbsp;&nbsp;</span>// specially.
<span id="L11" class="ln">    11&nbsp;&nbsp;</span>
<span id="L12" class="ln">    12&nbsp;&nbsp;</span>// This works on power8 and above. The loads and
<span id="L13" class="ln">    13&nbsp;&nbsp;</span>// compares are done in big endian order
<span id="L14" class="ln">    14&nbsp;&nbsp;</span>// since that allows the used of VCLZD, and allows
<span id="L15" class="ln">    15&nbsp;&nbsp;</span>// the same implementation to work on big and little
<span id="L16" class="ln">    16&nbsp;&nbsp;</span>// endian platforms with minimal conditional changes.
<span id="L17" class="ln">    17&nbsp;&nbsp;</span>
<span id="L18" class="ln">    18&nbsp;&nbsp;</span>// NOTE: There is a power9 implementation that
<span id="L19" class="ln">    19&nbsp;&nbsp;</span>// improves performance by 10-15% on little
<span id="L20" class="ln">    20&nbsp;&nbsp;</span>// endian for some of the benchmarks.
<span id="L21" class="ln">    21&nbsp;&nbsp;</span>// Unrolled index2to16 loop by 4 on ppc64le/power9
<span id="L22" class="ln">    22&nbsp;&nbsp;</span>// Work is still needed for a big endian
<span id="L23" class="ln">    23&nbsp;&nbsp;</span>// implementation on power9.
<span id="L24" class="ln">    24&nbsp;&nbsp;</span>
<span id="L25" class="ln">    25&nbsp;&nbsp;</span>//go:build ppc64 || ppc64le
<span id="L26" class="ln">    26&nbsp;&nbsp;</span>
<span id="L27" class="ln">    27&nbsp;&nbsp;</span>#include &#34;go_asm.h&#34;
<span id="L28" class="ln">    28&nbsp;&nbsp;</span>#include &#34;textflag.h&#34;
<span id="L29" class="ln">    29&nbsp;&nbsp;</span>
<span id="L30" class="ln">    30&nbsp;&nbsp;</span>// Needed to swap LXVD2X loads to the correct
<span id="L31" class="ln">    31&nbsp;&nbsp;</span>// byte order to work on POWER8.
<span id="L32" class="ln">    32&nbsp;&nbsp;</span>
<span id="L33" class="ln">    33&nbsp;&nbsp;</span>#ifdef GOARCH_ppc64
<span id="L34" class="ln">    34&nbsp;&nbsp;</span>DATA byteswap&lt;&gt;+0(SB)/8, $0x0001020304050607
<span id="L35" class="ln">    35&nbsp;&nbsp;</span>DATA byteswap&lt;&gt;+8(SB)/8, $0x08090a0b0c0d0e0f
<span id="L36" class="ln">    36&nbsp;&nbsp;</span>#else
<span id="L37" class="ln">    37&nbsp;&nbsp;</span>DATA byteswap&lt;&gt;+0(SB)/8, $0x0706050403020100
<span id="L38" class="ln">    38&nbsp;&nbsp;</span>DATA byteswap&lt;&gt;+8(SB)/8, $0x0f0e0d0c0b0a0908
<span id="L39" class="ln">    39&nbsp;&nbsp;</span>#endif
<span id="L40" class="ln">    40&nbsp;&nbsp;</span>
<span id="L41" class="ln">    41&nbsp;&nbsp;</span>// Load bytes in big endian order. Address
<span id="L42" class="ln">    42&nbsp;&nbsp;</span>// alignment does not need checking.
<span id="L43" class="ln">    43&nbsp;&nbsp;</span>#define VLOADSWAP(base, index, vreg, vsreg) \
<span id="L44" class="ln">    44&nbsp;&nbsp;</span>	LXVD2X (base)(index), vsreg;  \
<span id="L45" class="ln">    45&nbsp;&nbsp;</span>	VPERM  vreg, vreg, SWAP, vreg
<span id="L46" class="ln">    46&nbsp;&nbsp;</span>
<span id="L47" class="ln">    47&nbsp;&nbsp;</span>GLOBL byteswap&lt;&gt;+0(SB), RODATA, $16
<span id="L48" class="ln">    48&nbsp;&nbsp;</span>
<span id="L49" class="ln">    49&nbsp;&nbsp;</span>TEXT ·Index&lt;ABIInternal&gt;(SB),NOSPLIT|NOFRAME,$0-56
<span id="L50" class="ln">    50&nbsp;&nbsp;</span>	// R3 = byte array pointer
<span id="L51" class="ln">    51&nbsp;&nbsp;</span>	// R4 = length
<span id="L52" class="ln">    52&nbsp;&nbsp;</span>	MOVD R6, R5             // R5 = separator pointer
<span id="L53" class="ln">    53&nbsp;&nbsp;</span>	MOVD R7, R6             // R6 = separator length
<span id="L54" class="ln">    54&nbsp;&nbsp;</span>
<span id="L55" class="ln">    55&nbsp;&nbsp;</span>#ifdef GOARCH_ppc64le
<span id="L56" class="ln">    56&nbsp;&nbsp;</span>	MOVBZ internal∕cpu·PPC64+const_offsetPPC64HasPOWER9(SB), R7
<span id="L57" class="ln">    57&nbsp;&nbsp;</span>	CMP   R7, $1
<span id="L58" class="ln">    58&nbsp;&nbsp;</span>	BNE   power8
<span id="L59" class="ln">    59&nbsp;&nbsp;</span>	BR    indexbodyp9&lt;&gt;(SB)
<span id="L60" class="ln">    60&nbsp;&nbsp;</span>#endif
<span id="L61" class="ln">    61&nbsp;&nbsp;</span>power8:
<span id="L62" class="ln">    62&nbsp;&nbsp;</span>	BR indexbody&lt;&gt;(SB)
<span id="L63" class="ln">    63&nbsp;&nbsp;</span>
<span id="L64" class="ln">    64&nbsp;&nbsp;</span>TEXT ·IndexString&lt;ABIInternal&gt;(SB),NOSPLIT|NOFRAME,$0-40
<span id="L65" class="ln">    65&nbsp;&nbsp;</span>	// R3 = string
<span id="L66" class="ln">    66&nbsp;&nbsp;</span>	// R4 = length
<span id="L67" class="ln">    67&nbsp;&nbsp;</span>	// R5 = separator pointer
<span id="L68" class="ln">    68&nbsp;&nbsp;</span>	// R6 = separator length
<span id="L69" class="ln">    69&nbsp;&nbsp;</span>
<span id="L70" class="ln">    70&nbsp;&nbsp;</span>#ifdef GOARCH_ppc64le
<span id="L71" class="ln">    71&nbsp;&nbsp;</span>	MOVBZ internal∕cpu·PPC64+const_offsetPPC64HasPOWER9(SB), R7
<span id="L72" class="ln">    72&nbsp;&nbsp;</span>	CMP   R7, $1
<span id="L73" class="ln">    73&nbsp;&nbsp;</span>	BNE   power8
<span id="L74" class="ln">    74&nbsp;&nbsp;</span>	BR    indexbodyp9&lt;&gt;(SB)
<span id="L75" class="ln">    75&nbsp;&nbsp;</span>
<span id="L76" class="ln">    76&nbsp;&nbsp;</span>#endif
<span id="L77" class="ln">    77&nbsp;&nbsp;</span>power8:
<span id="L78" class="ln">    78&nbsp;&nbsp;</span>	BR indexbody&lt;&gt;(SB)
<span id="L79" class="ln">    79&nbsp;&nbsp;</span>
<span id="L80" class="ln">    80&nbsp;&nbsp;</span>	// s: string we are searching
<span id="L81" class="ln">    81&nbsp;&nbsp;</span>	// sep: string to search for
<span id="L82" class="ln">    82&nbsp;&nbsp;</span>	// R3=&amp;s[0], R4=len(s)
<span id="L83" class="ln">    83&nbsp;&nbsp;</span>	// R5=&amp;sep[0], R6=len(sep)
<span id="L84" class="ln">    84&nbsp;&nbsp;</span>	// R14=&amp;ret (index where sep found)
<span id="L85" class="ln">    85&nbsp;&nbsp;</span>	// R7=working addr of string
<span id="L86" class="ln">    86&nbsp;&nbsp;</span>	// R16=index value 16
<span id="L87" class="ln">    87&nbsp;&nbsp;</span>	// R17=index value 17
<span id="L88" class="ln">    88&nbsp;&nbsp;</span>	// R18=index value 18
<span id="L89" class="ln">    89&nbsp;&nbsp;</span>	// R19=index value 1
<span id="L90" class="ln">    90&nbsp;&nbsp;</span>	// R26=LASTBYTE of string
<span id="L91" class="ln">    91&nbsp;&nbsp;</span>	// R27=LASTSTR last start byte to compare with sep
<span id="L92" class="ln">    92&nbsp;&nbsp;</span>	// R8, R9 scratch
<span id="L93" class="ln">    93&nbsp;&nbsp;</span>	// V0=sep left justified zero fill
<span id="L94" class="ln">    94&nbsp;&nbsp;</span>	// CR4=sep length &gt;= 16
<span id="L95" class="ln">    95&nbsp;&nbsp;</span>
<span id="L96" class="ln">    96&nbsp;&nbsp;</span>#define SEPMASK V17
<span id="L97" class="ln">    97&nbsp;&nbsp;</span>#define LASTBYTE R26
<span id="L98" class="ln">    98&nbsp;&nbsp;</span>#define LASTSTR R27
<span id="L99" class="ln">    99&nbsp;&nbsp;</span>#define ONES V20
<span id="L100" class="ln">   100&nbsp;&nbsp;</span>#define SWAP V21
<span id="L101" class="ln">   101&nbsp;&nbsp;</span>#define SWAP_ VS53
<span id="L102" class="ln">   102&nbsp;&nbsp;</span>TEXT indexbody&lt;&gt;(SB), NOSPLIT|NOFRAME, $0
<span id="L103" class="ln">   103&nbsp;&nbsp;</span>	CMP      R6, R4                 // Compare lengths
<span id="L104" class="ln">   104&nbsp;&nbsp;</span>	BGT      notfound               // If sep len is &gt; string, notfound
<span id="L105" class="ln">   105&nbsp;&nbsp;</span>	ADD      R4, R3, LASTBYTE       // find last byte addr
<span id="L106" class="ln">   106&nbsp;&nbsp;</span>	SUB      R6, LASTBYTE, LASTSTR  // LAST=&amp;s[len(s)-len(sep)] (last valid start index)
<span id="L107" class="ln">   107&nbsp;&nbsp;</span>	CMP      R6, $0                 // Check sep len
<span id="L108" class="ln">   108&nbsp;&nbsp;</span>	BEQ      notfound               // sep len 0 -- not found
<span id="L109" class="ln">   109&nbsp;&nbsp;</span>	MOVD     R3, R7                 // Copy of string addr
<span id="L110" class="ln">   110&nbsp;&nbsp;</span>	MOVD     $16, R16               // Index value 16
<span id="L111" class="ln">   111&nbsp;&nbsp;</span>	MOVD     $17, R17               // Index value 17
<span id="L112" class="ln">   112&nbsp;&nbsp;</span>	MOVD     $18, R18               // Index value 18
<span id="L113" class="ln">   113&nbsp;&nbsp;</span>	MOVD     $1, R19                // Index value 1
<span id="L114" class="ln">   114&nbsp;&nbsp;</span>	MOVD     $byteswap&lt;&gt;+00(SB), R8
<span id="L115" class="ln">   115&nbsp;&nbsp;</span>	VSPLTISB $0xFF, ONES            // splat all 1s
<span id="L116" class="ln">   116&nbsp;&nbsp;</span>	LXVD2X   (R8)(R0), SWAP_        // Set up swap string
<span id="L117" class="ln">   117&nbsp;&nbsp;</span>
<span id="L118" class="ln">   118&nbsp;&nbsp;</span>	CMP    R6, $16, CR4        // CR4 for len(sep) &gt;= 16
<span id="L119" class="ln">   119&nbsp;&nbsp;</span>	VOR    ONES, ONES, SEPMASK // Set up full SEPMASK
<span id="L120" class="ln">   120&nbsp;&nbsp;</span>	BGE    CR4, loadge16       // Load for len(sep) &gt;= 16
<span id="L121" class="ln">   121&nbsp;&nbsp;</span>	SUB    R6, R16, R9         // 16-len of sep
<span id="L122" class="ln">   122&nbsp;&nbsp;</span>	SLD    $3, R9              // Set up for VSLO
<span id="L123" class="ln">   123&nbsp;&nbsp;</span>	MTVSRD R9, V9              // Set up for VSLO
<span id="L124" class="ln">   124&nbsp;&nbsp;</span>	VSLDOI $8, V9, V9, V9      // Set up for VSLO
<span id="L125" class="ln">   125&nbsp;&nbsp;</span>	VSLO   ONES, V9, SEPMASK   // Mask for separator len(sep) &lt; 16
<span id="L126" class="ln">   126&nbsp;&nbsp;</span>
<span id="L127" class="ln">   127&nbsp;&nbsp;</span>loadge16:
<span id="L128" class="ln">   128&nbsp;&nbsp;</span>	ANDCC $15, R5, R9 // Find byte offset of sep
<span id="L129" class="ln">   129&nbsp;&nbsp;</span>	ADD   R9, R6, R10 // Add sep len
<span id="L130" class="ln">   130&nbsp;&nbsp;</span>	CMP   R10, $16    // Check if sep len+offset &gt; 16
<span id="L131" class="ln">   131&nbsp;&nbsp;</span>	BGT   sepcross16  // Sep crosses 16 byte boundary
<span id="L132" class="ln">   132&nbsp;&nbsp;</span>
<span id="L133" class="ln">   133&nbsp;&nbsp;</span>	RLDICR $0, R5, $59, R8 // Adjust addr to 16 byte container
<span id="L134" class="ln">   134&nbsp;&nbsp;</span>	VLOADSWAP(R8, R0, V0, V0) // Load 16 bytes @R8 into V0
<span id="L135" class="ln">   135&nbsp;&nbsp;</span>	SLD    $3, R9          // Set up shift count for VSLO
<span id="L136" class="ln">   136&nbsp;&nbsp;</span>	MTVSRD R9, V8         // Set up shift count for VSLO
<span id="L137" class="ln">   137&nbsp;&nbsp;</span>	VSLDOI $8, V8, V8, V8
<span id="L138" class="ln">   138&nbsp;&nbsp;</span>	VSLO   V0, V8, V0      // Shift by start byte
<span id="L139" class="ln">   139&nbsp;&nbsp;</span>
<span id="L140" class="ln">   140&nbsp;&nbsp;</span>	VAND V0, SEPMASK, V0 // Mask separator (&lt; 16)
<span id="L141" class="ln">   141&nbsp;&nbsp;</span>	BR   index2plus
<span id="L142" class="ln">   142&nbsp;&nbsp;</span>
<span id="L143" class="ln">   143&nbsp;&nbsp;</span>sepcross16:
<span id="L144" class="ln">   144&nbsp;&nbsp;</span>	VLOADSWAP(R5, R0, V0, V0)  // Load 16 bytes @R5 into V0
<span id="L145" class="ln">   145&nbsp;&nbsp;</span>
<span id="L146" class="ln">   146&nbsp;&nbsp;</span>	VAND V0, SEPMASK, V0 // mask out separator
<span id="L147" class="ln">   147&nbsp;&nbsp;</span>	BLE  CR4, index2to16
<span id="L148" class="ln">   148&nbsp;&nbsp;</span>	BR   index17plus     // Handle sep &gt; 16
<span id="L149" class="ln">   149&nbsp;&nbsp;</span>
<span id="L150" class="ln">   150&nbsp;&nbsp;</span>index2plus:
<span id="L151" class="ln">   151&nbsp;&nbsp;</span>	CMP      R6, $2       // Check length of sep
<span id="L152" class="ln">   152&nbsp;&nbsp;</span>	BNE      index3plus   // If not 2, check for 3
<span id="L153" class="ln">   153&nbsp;&nbsp;</span>	ADD      $16, R7, R9  // Check if next 16 bytes past last
<span id="L154" class="ln">   154&nbsp;&nbsp;</span>	CMP      R9, LASTBYTE // compare with last
<span id="L155" class="ln">   155&nbsp;&nbsp;</span>	BGE      index2to16   // 2 &lt;= len(string) &lt;= 16
<span id="L156" class="ln">   156&nbsp;&nbsp;</span>	MOVD     $0xff00, R21 // Mask for later
<span id="L157" class="ln">   157&nbsp;&nbsp;</span>	MTVSRD   R21, V25     // Move to Vreg
<span id="L158" class="ln">   158&nbsp;&nbsp;</span>	VSPLTH   $3, V25, V31 // Splat mask
<span id="L159" class="ln">   159&nbsp;&nbsp;</span>	VSPLTH   $0, V0, V1   // Splat 1st 2 bytes of sep
<span id="L160" class="ln">   160&nbsp;&nbsp;</span>	VSPLTISB $0, V10      // Clear V10
<span id="L161" class="ln">   161&nbsp;&nbsp;</span>
<span id="L162" class="ln">   162&nbsp;&nbsp;</span>	// First case: 2 byte separator
<span id="L163" class="ln">   163&nbsp;&nbsp;</span>	// V1: 2 byte separator splatted
<span id="L164" class="ln">   164&nbsp;&nbsp;</span>	// V2: 16 bytes at addr
<span id="L165" class="ln">   165&nbsp;&nbsp;</span>	// V4: 16 bytes at addr+1
<span id="L166" class="ln">   166&nbsp;&nbsp;</span>	// Compare 2 byte separator at start
<span id="L167" class="ln">   167&nbsp;&nbsp;</span>	// and at start+1. Use VSEL to combine
<span id="L168" class="ln">   168&nbsp;&nbsp;</span>	// those results to find the first
<span id="L169" class="ln">   169&nbsp;&nbsp;</span>	// matching start byte, returning
<span id="L170" class="ln">   170&nbsp;&nbsp;</span>	// that value when found. Loop as
<span id="L171" class="ln">   171&nbsp;&nbsp;</span>	// long as len(string) &gt; 16
<span id="L172" class="ln">   172&nbsp;&nbsp;</span>index2loop2:
<span id="L173" class="ln">   173&nbsp;&nbsp;</span>	VLOADSWAP(R7, R19, V3, V3) // Load 16 bytes @R7+1 into V3
<span id="L174" class="ln">   174&nbsp;&nbsp;</span>
<span id="L175" class="ln">   175&nbsp;&nbsp;</span>index2loop:
<span id="L176" class="ln">   176&nbsp;&nbsp;</span>	VLOADSWAP(R7, R0, V2, V2)  // Load 16 bytes @R7 into V2
<span id="L177" class="ln">   177&nbsp;&nbsp;</span>	VCMPEQUH V1, V2, V5        // Search for sep
<span id="L178" class="ln">   178&nbsp;&nbsp;</span>	VCMPEQUH V1, V3, V6        // Search for sep offset by 1
<span id="L179" class="ln">   179&nbsp;&nbsp;</span>	VSEL     V6, V5, V31, V7   // merge even and odd indices
<span id="L180" class="ln">   180&nbsp;&nbsp;</span>	VCLZD    V7, V18           // find index of first match
<span id="L181" class="ln">   181&nbsp;&nbsp;</span>	MFVSRD   V18, R25          // get first value
<span id="L182" class="ln">   182&nbsp;&nbsp;</span>	CMP      R25, $64          // Found if &lt; 64
<span id="L183" class="ln">   183&nbsp;&nbsp;</span>	BLT      foundR25          // Return byte index where found
<span id="L184" class="ln">   184&nbsp;&nbsp;</span>	VSLDOI   $8, V18, V18, V18 // Adjust 2nd value
<span id="L185" class="ln">   185&nbsp;&nbsp;</span>	MFVSRD   V18, R25          // get second value
<span id="L186" class="ln">   186&nbsp;&nbsp;</span>	CMP      R25, $64          // Found if &lt; 64
<span id="L187" class="ln">   187&nbsp;&nbsp;</span>	ADD      $64, R25          // Update byte offset
<span id="L188" class="ln">   188&nbsp;&nbsp;</span>	BLT      foundR25          // Return value
<span id="L189" class="ln">   189&nbsp;&nbsp;</span>	ADD      $16, R7           // R7+=16 Update string pointer
<span id="L190" class="ln">   190&nbsp;&nbsp;</span>	ADD      $17, R7, R9       // R9=F7+17 since loop unrolled
<span id="L191" class="ln">   191&nbsp;&nbsp;</span>	CMP      R9, LASTBYTE      // Compare addr+17 against last byte
<span id="L192" class="ln">   192&nbsp;&nbsp;</span>	BLT      index2loop2       // If &lt; last, continue loop
<span id="L193" class="ln">   193&nbsp;&nbsp;</span>	CMP      R7, LASTBYTE      // Compare addr+16 against last byte
<span id="L194" class="ln">   194&nbsp;&nbsp;</span>	BLT      index2to16        // If &lt; 16 handle specially
<span id="L195" class="ln">   195&nbsp;&nbsp;</span>	VLOADSWAP(R7, R0, V3, V3) // Load 16 bytes @R7 into V3
<span id="L196" class="ln">   196&nbsp;&nbsp;</span>	VSLDOI   $1, V3, V10, V3   // Shift left by 1 byte
<span id="L197" class="ln">   197&nbsp;&nbsp;</span>	BR       index2loop
<span id="L198" class="ln">   198&nbsp;&nbsp;</span>
<span id="L199" class="ln">   199&nbsp;&nbsp;</span>index3plus:
<span id="L200" class="ln">   200&nbsp;&nbsp;</span>	CMP    R6, $3       // Check if sep == 3
<span id="L201" class="ln">   201&nbsp;&nbsp;</span>	BNE    index4plus   // If not check larger
<span id="L202" class="ln">   202&nbsp;&nbsp;</span>	ADD    $19, R7, R9  // Find bytes for use in this loop
<span id="L203" class="ln">   203&nbsp;&nbsp;</span>	CMP    R9, LASTBYTE // Compare against last byte
<span id="L204" class="ln">   204&nbsp;&nbsp;</span>	BGE    index2to16   // Remaining string 2&lt;=len&lt;=16
<span id="L205" class="ln">   205&nbsp;&nbsp;</span>	MOVD   $0xff00, R21 // Set up mask for upcoming loop
<span id="L206" class="ln">   206&nbsp;&nbsp;</span>	MTVSRD R21, V25     // Move mask to Vreg
<span id="L207" class="ln">   207&nbsp;&nbsp;</span>	VSPLTH $3, V25, V31 // Splat mask
<span id="L208" class="ln">   208&nbsp;&nbsp;</span>	VSPLTH $0, V0, V1   // Splat 1st two bytes of sep
<span id="L209" class="ln">   209&nbsp;&nbsp;</span>	VSPLTB $2, V0, V8   // Splat 3rd byte of sep
<span id="L210" class="ln">   210&nbsp;&nbsp;</span>
<span id="L211" class="ln">   211&nbsp;&nbsp;</span>	// Loop to process 3 byte separator.
<span id="L212" class="ln">   212&nbsp;&nbsp;</span>	// string[0:16] is in V2
<span id="L213" class="ln">   213&nbsp;&nbsp;</span>	// string[2:18] is in V3
<span id="L214" class="ln">   214&nbsp;&nbsp;</span>	// sep[0:2] splatted in V1
<span id="L215" class="ln">   215&nbsp;&nbsp;</span>	// sec[3] splatted in v8
<span id="L216" class="ln">   216&nbsp;&nbsp;</span>	// Load vectors at string, string+1
<span id="L217" class="ln">   217&nbsp;&nbsp;</span>	// and string+2. Compare string, string+1
<span id="L218" class="ln">   218&nbsp;&nbsp;</span>	// against first 2 bytes of separator
<span id="L219" class="ln">   219&nbsp;&nbsp;</span>	// splatted, and string+2 against 3rd
<span id="L220" class="ln">   220&nbsp;&nbsp;</span>	// byte splatted. Merge the results with
<span id="L221" class="ln">   221&nbsp;&nbsp;</span>	// VSEL to find the first byte of a match.
<span id="L222" class="ln">   222&nbsp;&nbsp;</span>
<span id="L223" class="ln">   223&nbsp;&nbsp;</span>	// Special handling for last 16 bytes if the
<span id="L224" class="ln">   224&nbsp;&nbsp;</span>	// string fits in 16 byte multiple.
<span id="L225" class="ln">   225&nbsp;&nbsp;</span>index3loop2:
<span id="L226" class="ln">   226&nbsp;&nbsp;</span>	MOVD     $2, R21          // Set up index for 2
<span id="L227" class="ln">   227&nbsp;&nbsp;</span>	VSPLTISB $0, V10          // Clear V10
<span id="L228" class="ln">   228&nbsp;&nbsp;</span>	VLOADSWAP(R7, R21, V3, V3)// Load 16 bytes @R7+2 into V3
<span id="L229" class="ln">   229&nbsp;&nbsp;</span>	VSLDOI   $14, V3, V10, V3 // Left justify next 2 bytes
<span id="L230" class="ln">   230&nbsp;&nbsp;</span>
<span id="L231" class="ln">   231&nbsp;&nbsp;</span>index3loop:
<span id="L232" class="ln">   232&nbsp;&nbsp;</span>	VLOADSWAP(R7, R0, V2, V2)  // Load with correct order
<span id="L233" class="ln">   233&nbsp;&nbsp;</span>	VSLDOI   $1, V2, V3, V4    // string[1:17]
<span id="L234" class="ln">   234&nbsp;&nbsp;</span>	VSLDOI   $2, V2, V3, V9    // string[2:18]
<span id="L235" class="ln">   235&nbsp;&nbsp;</span>	VCMPEQUH V1, V2, V5        // compare hw even indices
<span id="L236" class="ln">   236&nbsp;&nbsp;</span>	VCMPEQUH V1, V4, V6        // compare hw odd indices
<span id="L237" class="ln">   237&nbsp;&nbsp;</span>	VCMPEQUB V8, V9, V10       // compare 3rd to last byte
<span id="L238" class="ln">   238&nbsp;&nbsp;</span>	VSEL     V6, V5, V31, V7   // Find 1st matching byte using mask
<span id="L239" class="ln">   239&nbsp;&nbsp;</span>	VAND     V7, V10, V7       // AND matched bytes with matched 3rd byte
<span id="L240" class="ln">   240&nbsp;&nbsp;</span>	VCLZD    V7, V18           // Find first nonzero indexes
<span id="L241" class="ln">   241&nbsp;&nbsp;</span>	MFVSRD   V18, R25          // Move 1st doubleword
<span id="L242" class="ln">   242&nbsp;&nbsp;</span>	CMP      R25, $64          // If &lt; 64 found
<span id="L243" class="ln">   243&nbsp;&nbsp;</span>	BLT      foundR25          // Return matching index
<span id="L244" class="ln">   244&nbsp;&nbsp;</span>	VSLDOI   $8, V18, V18, V18 // Move value
<span id="L245" class="ln">   245&nbsp;&nbsp;</span>	MFVSRD   V18, R25          // Move 2nd doubleword
<span id="L246" class="ln">   246&nbsp;&nbsp;</span>	CMP      R25, $64          // If &lt; 64 found
<span id="L247" class="ln">   247&nbsp;&nbsp;</span>	ADD      $64, R25          // Update byte index
<span id="L248" class="ln">   248&nbsp;&nbsp;</span>	BLT      foundR25          // Return matching index
<span id="L249" class="ln">   249&nbsp;&nbsp;</span>	ADD      $16, R7           // R7+=16 string ptr
<span id="L250" class="ln">   250&nbsp;&nbsp;</span>	ADD      $19, R7, R9       // Number of string bytes for loop
<span id="L251" class="ln">   251&nbsp;&nbsp;</span>	CMP      R9, LASTBYTE      // Compare against last byte of string
<span id="L252" class="ln">   252&nbsp;&nbsp;</span>	BLT      index3loop2       // If within, continue this loop
<span id="L253" class="ln">   253&nbsp;&nbsp;</span>	CMP      R7, LASTSTR       // Compare against last start byte
<span id="L254" class="ln">   254&nbsp;&nbsp;</span>	BLT      index2to16        // Process remainder
<span id="L255" class="ln">   255&nbsp;&nbsp;</span>	VSPLTISB $0, V3            // Special case for last 16 bytes
<span id="L256" class="ln">   256&nbsp;&nbsp;</span>	BR       index3loop        // Continue this loop
<span id="L257" class="ln">   257&nbsp;&nbsp;</span>
<span id="L258" class="ln">   258&nbsp;&nbsp;</span>	// Loop to process 4 byte separator
<span id="L259" class="ln">   259&nbsp;&nbsp;</span>	// string[0:16] in V2
<span id="L260" class="ln">   260&nbsp;&nbsp;</span>	// string[3:16] in V3
<span id="L261" class="ln">   261&nbsp;&nbsp;</span>	// sep[0:4] splatted in V1
<span id="L262" class="ln">   262&nbsp;&nbsp;</span>	// Set up vectors with strings at offsets
<span id="L263" class="ln">   263&nbsp;&nbsp;</span>	// 0, 1, 2, 3 and compare against the 4 byte
<span id="L264" class="ln">   264&nbsp;&nbsp;</span>	// separator also splatted. Use VSEL with the
<span id="L265" class="ln">   265&nbsp;&nbsp;</span>	// compare results to find the first byte where
<span id="L266" class="ln">   266&nbsp;&nbsp;</span>	// a separator match is found.
<span id="L267" class="ln">   267&nbsp;&nbsp;</span>index4plus:
<span id="L268" class="ln">   268&nbsp;&nbsp;</span>	CMP  R6, $4       // Check if 4 byte separator
<span id="L269" class="ln">   269&nbsp;&nbsp;</span>	BNE  index5plus   // If not next higher
<span id="L270" class="ln">   270&nbsp;&nbsp;</span>	ADD  $20, R7, R9  // Check string size to load
<span id="L271" class="ln">   271&nbsp;&nbsp;</span>	CMP  R9, LASTBYTE // Verify string length
<span id="L272" class="ln">   272&nbsp;&nbsp;</span>	BGE  index2to16   // If not large enough, process remaining
<span id="L273" class="ln">   273&nbsp;&nbsp;</span>	MOVD $2, R15      // Set up index
<span id="L274" class="ln">   274&nbsp;&nbsp;</span>
<span id="L275" class="ln">   275&nbsp;&nbsp;</span>	// Set up masks for use with VSEL
<span id="L276" class="ln">   276&nbsp;&nbsp;</span>	MOVD   $0xff, R21        // Set up mask 0xff000000ff000000...
<span id="L277" class="ln">   277&nbsp;&nbsp;</span>	SLD    $24, R21
<span id="L278" class="ln">   278&nbsp;&nbsp;</span>	MTVSRD R21, V10
<span id="L279" class="ln">   279&nbsp;&nbsp;</span>	VSPLTW $1, V10, V29
<span id="L280" class="ln">   280&nbsp;&nbsp;</span>	VSLDOI $2, V29, V29, V30 // Mask 0x0000ff000000ff00...
<span id="L281" class="ln">   281&nbsp;&nbsp;</span>	MOVD   $0xffff, R21
<span id="L282" class="ln">   282&nbsp;&nbsp;</span>	SLD    $16, R21
<span id="L283" class="ln">   283&nbsp;&nbsp;</span>	MTVSRD R21, V10
<span id="L284" class="ln">   284&nbsp;&nbsp;</span>	VSPLTW $1, V10, V31      // Mask 0xffff0000ffff0000...
<span id="L285" class="ln">   285&nbsp;&nbsp;</span>	VSPLTW $0, V0, V1        // Splat 1st word of separator
<span id="L286" class="ln">   286&nbsp;&nbsp;</span>
<span id="L287" class="ln">   287&nbsp;&nbsp;</span>index4loop:
<span id="L288" class="ln">   288&nbsp;&nbsp;</span>	VLOADSWAP(R7, R0, V2, V2)   // Load 16 bytes @R7 into V2
<span id="L289" class="ln">   289&nbsp;&nbsp;</span>
<span id="L290" class="ln">   290&nbsp;&nbsp;</span>next4:
<span id="L291" class="ln">   291&nbsp;&nbsp;</span>	VSPLTISB $0, V10            // Clear
<span id="L292" class="ln">   292&nbsp;&nbsp;</span>	MOVD     $3, R9             // Number of bytes beyond 16
<span id="L293" class="ln">   293&nbsp;&nbsp;</span>	VLOADSWAP(R7, R9, V3, V3)   // Load 16 bytes @R7+3 into V3
<span id="L294" class="ln">   294&nbsp;&nbsp;</span>	VSLDOI   $13, V3, V10, V3   // Shift left last 3 bytes
<span id="L295" class="ln">   295&nbsp;&nbsp;</span>	VSLDOI   $1, V2, V3, V4     // V4=(V2:V3)&lt;&lt;1
<span id="L296" class="ln">   296&nbsp;&nbsp;</span>	VSLDOI   $2, V2, V3, V9     // V9=(V2:V3)&lt;&lt;2
<span id="L297" class="ln">   297&nbsp;&nbsp;</span>	VSLDOI   $3, V2, V3, V10    // V10=(V2:v3)&lt;&lt;3
<span id="L298" class="ln">   298&nbsp;&nbsp;</span>	VCMPEQUW V1, V2, V5         // compare index 0, 4, ... with sep
<span id="L299" class="ln">   299&nbsp;&nbsp;</span>	VCMPEQUW V1, V4, V6         // compare index 1, 5, ... with sep
<span id="L300" class="ln">   300&nbsp;&nbsp;</span>	VCMPEQUW V1, V9, V11        // compare index 2, 6, ... with sep
<span id="L301" class="ln">   301&nbsp;&nbsp;</span>	VCMPEQUW V1, V10, V12       // compare index 3, 7, ... with sep
<span id="L302" class="ln">   302&nbsp;&nbsp;</span>	VSEL     V6, V5, V29, V13   // merge index 0, 1, 4, 5, using mask
<span id="L303" class="ln">   303&nbsp;&nbsp;</span>	VSEL     V12, V11, V30, V14 // merge index 2, 3, 6, 7, using mask
<span id="L304" class="ln">   304&nbsp;&nbsp;</span>	VSEL     V14, V13, V31, V7  // final merge
<span id="L305" class="ln">   305&nbsp;&nbsp;</span>	VCLZD    V7, V18            // Find first index for each half
<span id="L306" class="ln">   306&nbsp;&nbsp;</span>	MFVSRD   V18, R25           // Isolate value
<span id="L307" class="ln">   307&nbsp;&nbsp;</span>	CMP      R25, $64           // If &lt; 64, found
<span id="L308" class="ln">   308&nbsp;&nbsp;</span>	BLT      foundR25           // Return found index
<span id="L309" class="ln">   309&nbsp;&nbsp;</span>	VSLDOI   $8, V18, V18, V18  // Move for MFVSRD
<span id="L310" class="ln">   310&nbsp;&nbsp;</span>	MFVSRD   V18, R25           // Isolate other value
<span id="L311" class="ln">   311&nbsp;&nbsp;</span>	CMP      R25, $64           // If &lt; 64, found
<span id="L312" class="ln">   312&nbsp;&nbsp;</span>	ADD      $64, R25           // Update index for high doubleword
<span id="L313" class="ln">   313&nbsp;&nbsp;</span>	BLT      foundR25           // Return found index
<span id="L314" class="ln">   314&nbsp;&nbsp;</span>	ADD      $16, R7            // R7+=16 for next string
<span id="L315" class="ln">   315&nbsp;&nbsp;</span>	ADD      $20, R7, R9        // R+20 for all bytes to load
<span id="L316" class="ln">   316&nbsp;&nbsp;</span>	CMP      R9, LASTBYTE       // Past end? Maybe check for extra?
<span id="L317" class="ln">   317&nbsp;&nbsp;</span>	BLT      index4loop         // If not, continue loop
<span id="L318" class="ln">   318&nbsp;&nbsp;</span>	CMP      R7, LASTSTR        // Check remainder
<span id="L319" class="ln">   319&nbsp;&nbsp;</span>	BLE      index2to16         // Process remainder
<span id="L320" class="ln">   320&nbsp;&nbsp;</span>	BR       notfound           // Not found
<span id="L321" class="ln">   321&nbsp;&nbsp;</span>
<span id="L322" class="ln">   322&nbsp;&nbsp;</span>index5plus:
<span id="L323" class="ln">   323&nbsp;&nbsp;</span>	CMP R6, $16     // Check for sep &gt; 16
<span id="L324" class="ln">   324&nbsp;&nbsp;</span>	BGT index17plus // Handle large sep
<span id="L325" class="ln">   325&nbsp;&nbsp;</span>
<span id="L326" class="ln">   326&nbsp;&nbsp;</span>	// Assumption is that the separator is smaller than the string at this point
<span id="L327" class="ln">   327&nbsp;&nbsp;</span>index2to16:
<span id="L328" class="ln">   328&nbsp;&nbsp;</span>	CMP R7, LASTSTR // Compare last start byte
<span id="L329" class="ln">   329&nbsp;&nbsp;</span>	BGT notfound    // last takes len(sep) into account
<span id="L330" class="ln">   330&nbsp;&nbsp;</span>
<span id="L331" class="ln">   331&nbsp;&nbsp;</span>	ADD $16, R7, R9    // Check for last byte of string
<span id="L332" class="ln">   332&nbsp;&nbsp;</span>	CMP R9, LASTBYTE
<span id="L333" class="ln">   333&nbsp;&nbsp;</span>	BGT index2to16tail
<span id="L334" class="ln">   334&nbsp;&nbsp;</span>
<span id="L335" class="ln">   335&nbsp;&nbsp;</span>	// At least 16 bytes of string left
<span id="L336" class="ln">   336&nbsp;&nbsp;</span>	// Mask the number of bytes in sep
<span id="L337" class="ln">   337&nbsp;&nbsp;</span>index2to16loop:
<span id="L338" class="ln">   338&nbsp;&nbsp;</span>	VLOADSWAP(R7, R0, V1, V1)  // Load 16 bytes @R7 into V1
<span id="L339" class="ln">   339&nbsp;&nbsp;</span>
<span id="L340" class="ln">   340&nbsp;&nbsp;</span>compare:
<span id="L341" class="ln">   341&nbsp;&nbsp;</span>	VAND       V1, SEPMASK, V2 // Mask out sep size
<span id="L342" class="ln">   342&nbsp;&nbsp;</span>	VCMPEQUBCC V0, V2, V3      // Compare masked string
<span id="L343" class="ln">   343&nbsp;&nbsp;</span>	BLT        CR6, found      // All equal
<span id="L344" class="ln">   344&nbsp;&nbsp;</span>	ADD        $1, R7          // Update ptr to next byte
<span id="L345" class="ln">   345&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Still less than last start byte
<span id="L346" class="ln">   346&nbsp;&nbsp;</span>	BGT        notfound        // Not found
<span id="L347" class="ln">   347&nbsp;&nbsp;</span>	ADD        $16, R7, R9     // Verify remaining bytes
<span id="L348" class="ln">   348&nbsp;&nbsp;</span>	CMP        R9, LASTBYTE    // At least 16
<span id="L349" class="ln">   349&nbsp;&nbsp;</span>	BLT        index2to16loop  // Try again
<span id="L350" class="ln">   350&nbsp;&nbsp;</span>
<span id="L351" class="ln">   351&nbsp;&nbsp;</span>	// Less than 16 bytes remaining in string
<span id="L352" class="ln">   352&nbsp;&nbsp;</span>	// Separator &gt;= 2
<span id="L353" class="ln">   353&nbsp;&nbsp;</span>index2to16tail:
<span id="L354" class="ln">   354&nbsp;&nbsp;</span>	ADD   R3, R4, R9     // End of string
<span id="L355" class="ln">   355&nbsp;&nbsp;</span>	SUB   R7, R9, R9     // Number of bytes left
<span id="L356" class="ln">   356&nbsp;&nbsp;</span>	ANDCC $15, R7, R10   // 16 byte offset
<span id="L357" class="ln">   357&nbsp;&nbsp;</span>	ADD   R10, R9, R11   // offset + len
<span id="L358" class="ln">   358&nbsp;&nbsp;</span>	CMP   R11, $16       // &gt;= 16?
<span id="L359" class="ln">   359&nbsp;&nbsp;</span>	BLE   short          // Does not cross 16 bytes
<span id="L360" class="ln">   360&nbsp;&nbsp;</span>	VLOADSWAP(R7, R0, V1, V1) // Load 16 bytes @R7 into V1
<span id="L361" class="ln">   361&nbsp;&nbsp;</span>	BR    index2to16next // Continue on
<span id="L362" class="ln">   362&nbsp;&nbsp;</span>
<span id="L363" class="ln">   363&nbsp;&nbsp;</span>short:
<span id="L364" class="ln">   364&nbsp;&nbsp;</span>	RLDICR   $0, R7, $59, R9 // Adjust addr to 16 byte container
<span id="L365" class="ln">   365&nbsp;&nbsp;</span>	VLOADSWAP(R9, R0, V1, V1)// Load 16 bytes @R9 into V1
<span id="L366" class="ln">   366&nbsp;&nbsp;</span>	SLD      $3, R10         // Set up shift
<span id="L367" class="ln">   367&nbsp;&nbsp;</span>	MTVSRD   R10, V8         // Set up shift
<span id="L368" class="ln">   368&nbsp;&nbsp;</span>	VSLDOI   $8, V8, V8, V8
<span id="L369" class="ln">   369&nbsp;&nbsp;</span>	VSLO     V1, V8, V1      // Shift by start byte
<span id="L370" class="ln">   370&nbsp;&nbsp;</span>	VSPLTISB $0, V25         // Clear for later use
<span id="L371" class="ln">   371&nbsp;&nbsp;</span>
<span id="L372" class="ln">   372&nbsp;&nbsp;</span>index2to16next:
<span id="L373" class="ln">   373&nbsp;&nbsp;</span>	VAND       V1, SEPMASK, V2 // Just compare size of sep
<span id="L374" class="ln">   374&nbsp;&nbsp;</span>	VCMPEQUBCC V0, V2, V3      // Compare sep and partial string
<span id="L375" class="ln">   375&nbsp;&nbsp;</span>	BLT        CR6, found      // Found
<span id="L376" class="ln">   376&nbsp;&nbsp;</span>	ADD        $1, R7          // Not found, try next partial string
<span id="L377" class="ln">   377&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check for end of string
<span id="L378" class="ln">   378&nbsp;&nbsp;</span>	BGT        notfound        // If at end, then not found
<span id="L379" class="ln">   379&nbsp;&nbsp;</span>	VSLDOI     $1, V1, V25, V1 // Shift string left by 1 byte
<span id="L380" class="ln">   380&nbsp;&nbsp;</span>	BR         index2to16next  // Check the next partial string
<span id="L381" class="ln">   381&nbsp;&nbsp;</span>
<span id="L382" class="ln">   382&nbsp;&nbsp;</span>index17plus:
<span id="L383" class="ln">   383&nbsp;&nbsp;</span>	CMP      R6, $32      // Check if 17 &lt; len(sep) &lt;= 32
<span id="L384" class="ln">   384&nbsp;&nbsp;</span>	BGT      index33plus
<span id="L385" class="ln">   385&nbsp;&nbsp;</span>	SUB      $16, R6, R9  // Extra &gt; 16
<span id="L386" class="ln">   386&nbsp;&nbsp;</span>	SLD      $56, R9, R10 // Shift to use in VSLO
<span id="L387" class="ln">   387&nbsp;&nbsp;</span>	MTVSRD   R10, V9      // Set up for VSLO
<span id="L388" class="ln">   388&nbsp;&nbsp;</span>	VLOADSWAP(R5, R9, V1, V1)// Load 16 bytes @R5+R9 into V1
<span id="L389" class="ln">   389&nbsp;&nbsp;</span>	VSLO     V1, V9, V1   // Shift left
<span id="L390" class="ln">   390&nbsp;&nbsp;</span>	VSPLTISB $0xff, V7    // Splat 1s
<span id="L391" class="ln">   391&nbsp;&nbsp;</span>	VSPLTISB $0, V27      // Splat 0
<span id="L392" class="ln">   392&nbsp;&nbsp;</span>
<span id="L393" class="ln">   393&nbsp;&nbsp;</span>index17to32loop:
<span id="L394" class="ln">   394&nbsp;&nbsp;</span>	VLOADSWAP(R7, R0, V2, V2)  // Load 16 bytes @R7 into V2
<span id="L395" class="ln">   395&nbsp;&nbsp;</span>
<span id="L396" class="ln">   396&nbsp;&nbsp;</span>next17:
<span id="L397" class="ln">   397&nbsp;&nbsp;</span>	VLOADSWAP(R7, R9, V3, V3)  // Load 16 bytes @R7+R9 into V3
<span id="L398" class="ln">   398&nbsp;&nbsp;</span>	VSLO       V3, V9, V3      // Shift left
<span id="L399" class="ln">   399&nbsp;&nbsp;</span>	VCMPEQUB   V0, V2, V4      // Compare first 16 bytes
<span id="L400" class="ln">   400&nbsp;&nbsp;</span>	VCMPEQUB   V1, V3, V5      // Compare extra over 16 bytes
<span id="L401" class="ln">   401&nbsp;&nbsp;</span>	VAND       V4, V5, V6      // Check if both equal
<span id="L402" class="ln">   402&nbsp;&nbsp;</span>	VCMPEQUBCC V6, V7, V8      // All equal?
<span id="L403" class="ln">   403&nbsp;&nbsp;</span>	BLT        CR6, found      // Yes
<span id="L404" class="ln">   404&nbsp;&nbsp;</span>	ADD        $1, R7          // On to next byte
<span id="L405" class="ln">   405&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check if last start byte
<span id="L406" class="ln">   406&nbsp;&nbsp;</span>	BGT        notfound        // If too high, not found
<span id="L407" class="ln">   407&nbsp;&nbsp;</span>	BR         index17to32loop // Continue
<span id="L408" class="ln">   408&nbsp;&nbsp;</span>
<span id="L409" class="ln">   409&nbsp;&nbsp;</span>notfound:
<span id="L410" class="ln">   410&nbsp;&nbsp;</span>	MOVD $-1, R3   // Return -1 if not found
<span id="L411" class="ln">   411&nbsp;&nbsp;</span>	RET
<span id="L412" class="ln">   412&nbsp;&nbsp;</span>
<span id="L413" class="ln">   413&nbsp;&nbsp;</span>index33plus:
<span id="L414" class="ln">   414&nbsp;&nbsp;</span>	MOVD $0, (R0) // Case not implemented
<span id="L415" class="ln">   415&nbsp;&nbsp;</span>	RET           // Crash before return
<span id="L416" class="ln">   416&nbsp;&nbsp;</span>
<span id="L417" class="ln">   417&nbsp;&nbsp;</span>foundR25:
<span id="L418" class="ln">   418&nbsp;&nbsp;</span>	SRD  $3, R25   // Convert from bits to bytes
<span id="L419" class="ln">   419&nbsp;&nbsp;</span>	ADD  R25, R7   // Add to current string address
<span id="L420" class="ln">   420&nbsp;&nbsp;</span>	SUB  R3, R7    // Subtract from start of string
<span id="L421" class="ln">   421&nbsp;&nbsp;</span>	MOVD R7, R3    // Return byte where found
<span id="L422" class="ln">   422&nbsp;&nbsp;</span>	RET
<span id="L423" class="ln">   423&nbsp;&nbsp;</span>
<span id="L424" class="ln">   424&nbsp;&nbsp;</span>found:
<span id="L425" class="ln">   425&nbsp;&nbsp;</span>	SUB  R3, R7    // Return byte where found
<span id="L426" class="ln">   426&nbsp;&nbsp;</span>	MOVD R7, R3
<span id="L427" class="ln">   427&nbsp;&nbsp;</span>	RET
<span id="L428" class="ln">   428&nbsp;&nbsp;</span>
<span id="L429" class="ln">   429&nbsp;&nbsp;</span>TEXT indexbodyp9&lt;&gt;(SB), NOSPLIT|NOFRAME, $0
<span id="L430" class="ln">   430&nbsp;&nbsp;</span>	CMP      R6, R4                // Compare lengths
<span id="L431" class="ln">   431&nbsp;&nbsp;</span>	BGT      notfound              // If sep len is &gt; string, notfound
<span id="L432" class="ln">   432&nbsp;&nbsp;</span>	ADD      R4, R3, LASTBYTE      // find last byte addr
<span id="L433" class="ln">   433&nbsp;&nbsp;</span>	SUB      R6, LASTBYTE, LASTSTR // LAST=&amp;s[len(s)-len(sep)] (last valid start index)
<span id="L434" class="ln">   434&nbsp;&nbsp;</span>	CMP      R6, $0                // Check sep len
<span id="L435" class="ln">   435&nbsp;&nbsp;</span>	BEQ      notfound              // sep len 0 -- not found
<span id="L436" class="ln">   436&nbsp;&nbsp;</span>	MOVD     R3, R7                // Copy of string addr
<span id="L437" class="ln">   437&nbsp;&nbsp;</span>#ifndef GOPPC64_power10
<span id="L438" class="ln">   438&nbsp;&nbsp;</span>	MOVD     $16, R16              // Index value 16
<span id="L439" class="ln">   439&nbsp;&nbsp;</span>	MOVD     $17, R17              // Index value 17
<span id="L440" class="ln">   440&nbsp;&nbsp;</span>	MOVD     $18, R18              // Index value 18
<span id="L441" class="ln">   441&nbsp;&nbsp;</span>	VSPLTISB $0xFF, ONES           // splat all 1s
<span id="L442" class="ln">   442&nbsp;&nbsp;</span>	VOR    ONES, ONES, SEPMASK // Set up full SEPMASK
<span id="L443" class="ln">   443&nbsp;&nbsp;</span>#else
<span id="L444" class="ln">   444&nbsp;&nbsp;</span>	SLD     $56, R6, R14       // Set up separator length for LXVLL
<span id="L445" class="ln">   445&nbsp;&nbsp;</span>#endif
<span id="L446" class="ln">   446&nbsp;&nbsp;</span>	MOVD   $1, R19             // Index value 1
<span id="L447" class="ln">   447&nbsp;&nbsp;</span>	CMP    R6, $16, CR4        // CR4 for len(sep) &gt;= 16
<span id="L448" class="ln">   448&nbsp;&nbsp;</span>	BGE    CR4, loadge16       // Load for len(sep) &gt;= 16
<span id="L449" class="ln">   449&nbsp;&nbsp;</span>#ifndef GOPPC64_power10
<span id="L450" class="ln">   450&nbsp;&nbsp;</span>	SUB    R6, R16, R9         // 16-len of sep
<span id="L451" class="ln">   451&nbsp;&nbsp;</span>	SLD    $3, R9              // Set up for VSLO
<span id="L452" class="ln">   452&nbsp;&nbsp;</span>	MTVSRD R9, V9              // Set up for VSLO
<span id="L453" class="ln">   453&nbsp;&nbsp;</span>	VSLDOI $8, V9, V9, V9      // Set up for VSLO
<span id="L454" class="ln">   454&nbsp;&nbsp;</span>	VSLO   ONES, V9, SEPMASK   // Mask for separator len(sep) &lt; 16
<span id="L455" class="ln">   455&nbsp;&nbsp;</span>#endif
<span id="L456" class="ln">   456&nbsp;&nbsp;</span>loadge16:
<span id="L457" class="ln">   457&nbsp;&nbsp;</span>	ANDCC $15, R5, R9 // Find byte offset of sep
<span id="L458" class="ln">   458&nbsp;&nbsp;</span>	ADD   R9, R6, R10 // Add sep len
<span id="L459" class="ln">   459&nbsp;&nbsp;</span>	CMP   R10, $16    // Check if sep len+offset &gt; 16
<span id="L460" class="ln">   460&nbsp;&nbsp;</span>	BGT   sepcross16  // Sep crosses 16 byte boundary
<span id="L461" class="ln">   461&nbsp;&nbsp;</span>#ifdef GOPPC64_power10
<span id="L462" class="ln">   462&nbsp;&nbsp;</span>	LXVLL   R5, R14, V0     // Load separator
<span id="L463" class="ln">   463&nbsp;&nbsp;</span>#else
<span id="L464" class="ln">   464&nbsp;&nbsp;</span>	RLDICR  $0, R5, $59, R8 // Adjust addr to 16 byte container
<span id="L465" class="ln">   465&nbsp;&nbsp;</span>	LXVB16X (R8)(R0), V0    // Load 16 bytes @R8 into V0
<span id="L466" class="ln">   466&nbsp;&nbsp;</span>	SLD     $3, R9          // Set up shift count for VSLO
<span id="L467" class="ln">   467&nbsp;&nbsp;</span>	MTVSRD  R9, V8          // Set up shift count for VSLO
<span id="L468" class="ln">   468&nbsp;&nbsp;</span>	VSLDOI  $8, V8, V8, V8
<span id="L469" class="ln">   469&nbsp;&nbsp;</span>	VSLO    V0, V8, V0      // Shift by start byte
<span id="L470" class="ln">   470&nbsp;&nbsp;</span>	VAND V0, SEPMASK, V0 // Mask separator (&lt; 16)
<span id="L471" class="ln">   471&nbsp;&nbsp;</span>#endif
<span id="L472" class="ln">   472&nbsp;&nbsp;</span>	BR  index2plus
<span id="L473" class="ln">   473&nbsp;&nbsp;</span>sepcross16:
<span id="L474" class="ln">   474&nbsp;&nbsp;</span>#ifdef GOPPC64_power10
<span id="L475" class="ln">   475&nbsp;&nbsp;</span>	LXVLL   R5, R14, V0     // Load separator
<span id="L476" class="ln">   476&nbsp;&nbsp;</span>#else
<span id="L477" class="ln">   477&nbsp;&nbsp;</span>	LXVB16X (R5)(R0), V0    // Load 16 bytes @R5 into V0\
<span id="L478" class="ln">   478&nbsp;&nbsp;</span>	VAND V0, SEPMASK, V0 // mask out separator
<span id="L479" class="ln">   479&nbsp;&nbsp;</span>#endif
<span id="L480" class="ln">   480&nbsp;&nbsp;</span>	BLE  CR4, index2to16
<span id="L481" class="ln">   481&nbsp;&nbsp;</span>	BR   index17plus     // Handle sep &gt; 16
<span id="L482" class="ln">   482&nbsp;&nbsp;</span>
<span id="L483" class="ln">   483&nbsp;&nbsp;</span>index2plus:
<span id="L484" class="ln">   484&nbsp;&nbsp;</span>	CMP      R6, $2       // Check length of sep
<span id="L485" class="ln">   485&nbsp;&nbsp;</span>	BNE      index3plus   // If not 2, check for 3
<span id="L486" class="ln">   486&nbsp;&nbsp;</span>	ADD      $16, R7, R9  // Check if next 16 bytes past last
<span id="L487" class="ln">   487&nbsp;&nbsp;</span>	CMP      R9, LASTBYTE // compare with last
<span id="L488" class="ln">   488&nbsp;&nbsp;</span>	BGE      index2to16   // 2 &lt;= len(string) &lt;= 16
<span id="L489" class="ln">   489&nbsp;&nbsp;</span>	MOVD     $0xff00, R21 // Mask for later
<span id="L490" class="ln">   490&nbsp;&nbsp;</span>	MTVSRD   R21, V25     // Move to Vreg
<span id="L491" class="ln">   491&nbsp;&nbsp;</span>	VSPLTH   $3, V25, V31 // Splat mask
<span id="L492" class="ln">   492&nbsp;&nbsp;</span>	VSPLTH   $0, V0, V1   // Splat 1st 2 bytes of sep
<span id="L493" class="ln">   493&nbsp;&nbsp;</span>	VSPLTISB $0, V10      // Clear V10
<span id="L494" class="ln">   494&nbsp;&nbsp;</span>
<span id="L495" class="ln">   495&nbsp;&nbsp;</span>	// First case: 2 byte separator
<span id="L496" class="ln">   496&nbsp;&nbsp;</span>	// V1: 2 byte separator splatted
<span id="L497" class="ln">   497&nbsp;&nbsp;</span>	// V2: 16 bytes at addr
<span id="L498" class="ln">   498&nbsp;&nbsp;</span>	// V4: 16 bytes at addr+1
<span id="L499" class="ln">   499&nbsp;&nbsp;</span>	// Compare 2 byte separator at start
<span id="L500" class="ln">   500&nbsp;&nbsp;</span>	// and at start+1. Use VSEL to combine
<span id="L501" class="ln">   501&nbsp;&nbsp;</span>	// those results to find the first
<span id="L502" class="ln">   502&nbsp;&nbsp;</span>	// matching start byte, returning
<span id="L503" class="ln">   503&nbsp;&nbsp;</span>	// that value when found. Loop as
<span id="L504" class="ln">   504&nbsp;&nbsp;</span>	// long as len(string) &gt; 16
<span id="L505" class="ln">   505&nbsp;&nbsp;</span>index2loop2:
<span id="L506" class="ln">   506&nbsp;&nbsp;</span>	LXVB16X (R7)(R19), V3  // Load 16 bytes @R7+1 into V3
<span id="L507" class="ln">   507&nbsp;&nbsp;</span>
<span id="L508" class="ln">   508&nbsp;&nbsp;</span>index2loop:
<span id="L509" class="ln">   509&nbsp;&nbsp;</span>	LXVB16X  (R7)(R0), V2    // Load 16 bytes @R7 into V2
<span id="L510" class="ln">   510&nbsp;&nbsp;</span>	VCMPEQUH V1, V2, V5      // Search for sep
<span id="L511" class="ln">   511&nbsp;&nbsp;</span>	VCMPEQUH V1, V3, V6      // Search for sep offset by 1
<span id="L512" class="ln">   512&nbsp;&nbsp;</span>	VSEL     V6, V5, V31, V7 // merge even and odd indices
<span id="L513" class="ln">   513&nbsp;&nbsp;</span>	VCLZD    V7, V18         // find index of first match
<span id="L514" class="ln">   514&nbsp;&nbsp;</span>	MFVSRD   V18, R25        // get first value
<span id="L515" class="ln">   515&nbsp;&nbsp;</span>	CMP      R25, $64        // Found if &lt; 64
<span id="L516" class="ln">   516&nbsp;&nbsp;</span>	BLT      foundR25        // Return byte index where found
<span id="L517" class="ln">   517&nbsp;&nbsp;</span>
<span id="L518" class="ln">   518&nbsp;&nbsp;</span>	MFVSRLD V18, R25        // get second value
<span id="L519" class="ln">   519&nbsp;&nbsp;</span>	CMP     R25, $64        // Found if &lt; 64
<span id="L520" class="ln">   520&nbsp;&nbsp;</span>	ADD     $64, R25        // Update byte offset
<span id="L521" class="ln">   521&nbsp;&nbsp;</span>	BLT     foundR25        // Return value
<span id="L522" class="ln">   522&nbsp;&nbsp;</span>	ADD     $16, R7         // R7+=16 Update string pointer
<span id="L523" class="ln">   523&nbsp;&nbsp;</span>	ADD     $17, R7, R9     // R9=F7+17 since loop unrolled
<span id="L524" class="ln">   524&nbsp;&nbsp;</span>	CMP     R9, LASTBYTE    // Compare addr+17 against last byte
<span id="L525" class="ln">   525&nbsp;&nbsp;</span>	BLT     index2loop2     // If &lt; last, continue loop
<span id="L526" class="ln">   526&nbsp;&nbsp;</span>	CMP     R7, LASTBYTE    // Compare addr+16 against last byte
<span id="L527" class="ln">   527&nbsp;&nbsp;</span>	BLT     index2to16      // If &lt; 16 handle specially
<span id="L528" class="ln">   528&nbsp;&nbsp;</span>	LXVB16X (R7)(R0), V3    // Load 16 bytes @R7 into V3
<span id="L529" class="ln">   529&nbsp;&nbsp;</span>	VSLDOI  $1, V3, V10, V3 // Shift left by 1 byte
<span id="L530" class="ln">   530&nbsp;&nbsp;</span>	BR      index2loop
<span id="L531" class="ln">   531&nbsp;&nbsp;</span>
<span id="L532" class="ln">   532&nbsp;&nbsp;</span>index3plus:
<span id="L533" class="ln">   533&nbsp;&nbsp;</span>	CMP    R6, $3       // Check if sep == 3
<span id="L534" class="ln">   534&nbsp;&nbsp;</span>	BNE    index4plus   // If not check larger
<span id="L535" class="ln">   535&nbsp;&nbsp;</span>	ADD    $19, R7, R9  // Find bytes for use in this loop
<span id="L536" class="ln">   536&nbsp;&nbsp;</span>	CMP    R9, LASTBYTE // Compare against last byte
<span id="L537" class="ln">   537&nbsp;&nbsp;</span>	BGE    index2to16   // Remaining string 2&lt;=len&lt;=16
<span id="L538" class="ln">   538&nbsp;&nbsp;</span>	MOVD   $0xff00, R21 // Set up mask for upcoming loop
<span id="L539" class="ln">   539&nbsp;&nbsp;</span>	MTVSRD R21, V25     // Move mask to Vreg
<span id="L540" class="ln">   540&nbsp;&nbsp;</span>	VSPLTH $3, V25, V31 // Splat mask
<span id="L541" class="ln">   541&nbsp;&nbsp;</span>	VSPLTH $0, V0, V1   // Splat 1st two bytes of sep
<span id="L542" class="ln">   542&nbsp;&nbsp;</span>	VSPLTB $2, V0, V8   // Splat 3rd byte of sep
<span id="L543" class="ln">   543&nbsp;&nbsp;</span>
<span id="L544" class="ln">   544&nbsp;&nbsp;</span>	// Loop to process 3 byte separator.
<span id="L545" class="ln">   545&nbsp;&nbsp;</span>	// string[0:16] is in V2
<span id="L546" class="ln">   546&nbsp;&nbsp;</span>	// string[2:18] is in V3
<span id="L547" class="ln">   547&nbsp;&nbsp;</span>	// sep[0:2] splatted in V1
<span id="L548" class="ln">   548&nbsp;&nbsp;</span>	// sec[3] splatted in v8
<span id="L549" class="ln">   549&nbsp;&nbsp;</span>	// Load vectors at string, string+1
<span id="L550" class="ln">   550&nbsp;&nbsp;</span>	// and string+2. Compare string, string+1
<span id="L551" class="ln">   551&nbsp;&nbsp;</span>	// against first 2 bytes of separator
<span id="L552" class="ln">   552&nbsp;&nbsp;</span>	// splatted, and string+2 against 3rd
<span id="L553" class="ln">   553&nbsp;&nbsp;</span>	// byte splatted. Merge the results with
<span id="L554" class="ln">   554&nbsp;&nbsp;</span>	// VSEL to find the first byte of a match.
<span id="L555" class="ln">   555&nbsp;&nbsp;</span>
<span id="L556" class="ln">   556&nbsp;&nbsp;</span>	// Special handling for last 16 bytes if the
<span id="L557" class="ln">   557&nbsp;&nbsp;</span>	// string fits in 16 byte multiple.
<span id="L558" class="ln">   558&nbsp;&nbsp;</span>index3loop2:
<span id="L559" class="ln">   559&nbsp;&nbsp;</span>	MOVD     $2, R21          // Set up index for 2
<span id="L560" class="ln">   560&nbsp;&nbsp;</span>	VSPLTISB $0, V10          // Clear V10
<span id="L561" class="ln">   561&nbsp;&nbsp;</span>	LXVB16X  (R7)(R21), V3    // Load 16 bytes @R7+2 into V3
<span id="L562" class="ln">   562&nbsp;&nbsp;</span>	VSLDOI   $14, V3, V10, V3 // Left justify next 2 bytes
<span id="L563" class="ln">   563&nbsp;&nbsp;</span>
<span id="L564" class="ln">   564&nbsp;&nbsp;</span>index3loop:
<span id="L565" class="ln">   565&nbsp;&nbsp;</span>	LXVB16X  (R7)(R0), V2    // Load 16 bytes @R7
<span id="L566" class="ln">   566&nbsp;&nbsp;</span>	VSLDOI   $1, V2, V3, V4  // string[1:17]
<span id="L567" class="ln">   567&nbsp;&nbsp;</span>	VSLDOI   $2, V2, V3, V9  // string[2:18]
<span id="L568" class="ln">   568&nbsp;&nbsp;</span>	VCMPEQUH V1, V2, V5      // compare hw even indices
<span id="L569" class="ln">   569&nbsp;&nbsp;</span>	VCMPEQUH V1, V4, V6      // compare hw odd indices
<span id="L570" class="ln">   570&nbsp;&nbsp;</span>	VCMPEQUB V8, V9, V10     // compare 3rd to last byte
<span id="L571" class="ln">   571&nbsp;&nbsp;</span>	VSEL     V6, V5, V31, V7 // Find 1st matching byte using mask
<span id="L572" class="ln">   572&nbsp;&nbsp;</span>	VAND     V7, V10, V7     // AND matched bytes with matched 3rd byte
<span id="L573" class="ln">   573&nbsp;&nbsp;</span>	VCLZD    V7, V18         // Find first nonzero indexes
<span id="L574" class="ln">   574&nbsp;&nbsp;</span>	MFVSRD   V18, R25        // Move 1st doubleword
<span id="L575" class="ln">   575&nbsp;&nbsp;</span>	CMP      R25, $64        // If &lt; 64 found
<span id="L576" class="ln">   576&nbsp;&nbsp;</span>	BLT      foundR25        // Return matching index
<span id="L577" class="ln">   577&nbsp;&nbsp;</span>
<span id="L578" class="ln">   578&nbsp;&nbsp;</span>	MFVSRLD  V18, R25     // Move 2nd doubleword
<span id="L579" class="ln">   579&nbsp;&nbsp;</span>	CMP      R25, $64     // If &lt; 64 found
<span id="L580" class="ln">   580&nbsp;&nbsp;</span>	ADD      $64, R25     // Update byte index
<span id="L581" class="ln">   581&nbsp;&nbsp;</span>	BLT      foundR25     // Return matching index
<span id="L582" class="ln">   582&nbsp;&nbsp;</span>	ADD      $16, R7      // R7+=16 string ptr
<span id="L583" class="ln">   583&nbsp;&nbsp;</span>	ADD      $19, R7, R9  // Number of string bytes for loop
<span id="L584" class="ln">   584&nbsp;&nbsp;</span>	CMP      R9, LASTBYTE // Compare against last byte of string
<span id="L585" class="ln">   585&nbsp;&nbsp;</span>	BLT      index3loop2  // If within, continue this loop
<span id="L586" class="ln">   586&nbsp;&nbsp;</span>	CMP      R7, LASTSTR  // Compare against last start byte
<span id="L587" class="ln">   587&nbsp;&nbsp;</span>	BLT      index2to16   // Process remainder
<span id="L588" class="ln">   588&nbsp;&nbsp;</span>	VSPLTISB $0, V3       // Special case for last 16 bytes
<span id="L589" class="ln">   589&nbsp;&nbsp;</span>	BR       index3loop   // Continue this loop
<span id="L590" class="ln">   590&nbsp;&nbsp;</span>
<span id="L591" class="ln">   591&nbsp;&nbsp;</span>	// Loop to process 4 byte separator
<span id="L592" class="ln">   592&nbsp;&nbsp;</span>	// string[0:16] in V2
<span id="L593" class="ln">   593&nbsp;&nbsp;</span>	// string[3:16] in V3
<span id="L594" class="ln">   594&nbsp;&nbsp;</span>	// sep[0:4] splatted in V1
<span id="L595" class="ln">   595&nbsp;&nbsp;</span>	// Set up vectors with strings at offsets
<span id="L596" class="ln">   596&nbsp;&nbsp;</span>	// 0, 1, 2, 3 and compare against the 4 byte
<span id="L597" class="ln">   597&nbsp;&nbsp;</span>	// separator also splatted. Use VSEL with the
<span id="L598" class="ln">   598&nbsp;&nbsp;</span>	// compare results to find the first byte where
<span id="L599" class="ln">   599&nbsp;&nbsp;</span>	// a separator match is found.
<span id="L600" class="ln">   600&nbsp;&nbsp;</span>index4plus:
<span id="L601" class="ln">   601&nbsp;&nbsp;</span>	CMP  R6, $4       // Check if 4 byte separator
<span id="L602" class="ln">   602&nbsp;&nbsp;</span>	BNE  index5plus   // If not next higher
<span id="L603" class="ln">   603&nbsp;&nbsp;</span>	ADD  $20, R7, R9  // Check string size to load
<span id="L604" class="ln">   604&nbsp;&nbsp;</span>	CMP  R9, LASTBYTE // Verify string length
<span id="L605" class="ln">   605&nbsp;&nbsp;</span>	BGE  index2to16   // If not large enough, process remaining
<span id="L606" class="ln">   606&nbsp;&nbsp;</span>
<span id="L607" class="ln">   607&nbsp;&nbsp;</span>	// Set up masks for use with VSEL
<span id="L608" class="ln">   608&nbsp;&nbsp;</span>	MOVD    $0xff, R21 // Set up mask 0xff000000ff000000...
<span id="L609" class="ln">   609&nbsp;&nbsp;</span>	SLD     $24, R21
<span id="L610" class="ln">   610&nbsp;&nbsp;</span>	MTVSRWS R21, V29
<span id="L611" class="ln">   611&nbsp;&nbsp;</span>
<span id="L612" class="ln">   612&nbsp;&nbsp;</span>	VSLDOI  $2, V29, V29, V30 // Mask 0x0000ff000000ff00...
<span id="L613" class="ln">   613&nbsp;&nbsp;</span>	MOVD    $0xffff, R21
<span id="L614" class="ln">   614&nbsp;&nbsp;</span>	SLD     $16, R21
<span id="L615" class="ln">   615&nbsp;&nbsp;</span>	MTVSRWS R21, V31
<span id="L616" class="ln">   616&nbsp;&nbsp;</span>
<span id="L617" class="ln">   617&nbsp;&nbsp;</span>	VSPLTW $0, V0, V1 // Splat 1st word of separator
<span id="L618" class="ln">   618&nbsp;&nbsp;</span>
<span id="L619" class="ln">   619&nbsp;&nbsp;</span>index4loop:
<span id="L620" class="ln">   620&nbsp;&nbsp;</span>	LXVB16X (R7)(R0), V2  // Load 16 bytes @R7 into V2
<span id="L621" class="ln">   621&nbsp;&nbsp;</span>
<span id="L622" class="ln">   622&nbsp;&nbsp;</span>next4:
<span id="L623" class="ln">   623&nbsp;&nbsp;</span>	VSPLTISB $0, V10            // Clear
<span id="L624" class="ln">   624&nbsp;&nbsp;</span>	MOVD     $3, R9             // Number of bytes beyond 16
<span id="L625" class="ln">   625&nbsp;&nbsp;</span>	LXVB16X  (R7)(R9), V3       // Load 16 bytes @R7 into V3
<span id="L626" class="ln">   626&nbsp;&nbsp;</span>	VSLDOI   $13, V3, V10, V3   // Shift left last 3 bytes
<span id="L627" class="ln">   627&nbsp;&nbsp;</span>	VSLDOI   $1, V2, V3, V4     // V4=(V2:V3)&lt;&lt;1
<span id="L628" class="ln">   628&nbsp;&nbsp;</span>	VSLDOI   $2, V2, V3, V9     // V9=(V2:V3)&lt;&lt;2
<span id="L629" class="ln">   629&nbsp;&nbsp;</span>	VSLDOI   $3, V2, V3, V10    // V10=(V2:v3)&lt;&lt;3
<span id="L630" class="ln">   630&nbsp;&nbsp;</span>	VCMPEQUW V1, V2, V5         // compare index 0, 4, ... with sep
<span id="L631" class="ln">   631&nbsp;&nbsp;</span>	VCMPEQUW V1, V4, V6         // compare index 1, 5, ... with sep
<span id="L632" class="ln">   632&nbsp;&nbsp;</span>	VCMPEQUW V1, V9, V11        // compare index 2, 6, ... with sep
<span id="L633" class="ln">   633&nbsp;&nbsp;</span>	VCMPEQUW V1, V10, V12       // compare index 3, 7, ... with sep
<span id="L634" class="ln">   634&nbsp;&nbsp;</span>	VSEL     V6, V5, V29, V13   // merge index 0, 1, 4, 5, using mask
<span id="L635" class="ln">   635&nbsp;&nbsp;</span>	VSEL     V12, V11, V30, V14 // merge index 2, 3, 6, 7, using mask
<span id="L636" class="ln">   636&nbsp;&nbsp;</span>	VSEL     V14, V13, V31, V7  // final merge
<span id="L637" class="ln">   637&nbsp;&nbsp;</span>	VCLZD    V7, V18            // Find first index for each half
<span id="L638" class="ln">   638&nbsp;&nbsp;</span>	MFVSRD   V18, R25           // Isolate value
<span id="L639" class="ln">   639&nbsp;&nbsp;</span>	CMP      R25, $64           // If &lt; 64, found
<span id="L640" class="ln">   640&nbsp;&nbsp;</span>	BLT      foundR25           // Return found index
<span id="L641" class="ln">   641&nbsp;&nbsp;</span>
<span id="L642" class="ln">   642&nbsp;&nbsp;</span>	MFVSRLD V18, R25     // Isolate other value
<span id="L643" class="ln">   643&nbsp;&nbsp;</span>	CMP     R25, $64     // If &lt; 64, found
<span id="L644" class="ln">   644&nbsp;&nbsp;</span>	ADD     $64, R25     // Update index for high doubleword
<span id="L645" class="ln">   645&nbsp;&nbsp;</span>	BLT     foundR25     // Return found index
<span id="L646" class="ln">   646&nbsp;&nbsp;</span>	ADD     $16, R7      // R7+=16 for next string
<span id="L647" class="ln">   647&nbsp;&nbsp;</span>	ADD     $20, R7, R9  // R+20 for all bytes to load
<span id="L648" class="ln">   648&nbsp;&nbsp;</span>	CMP     R9, LASTBYTE // Past end? Maybe check for extra?
<span id="L649" class="ln">   649&nbsp;&nbsp;</span>	BLT     index4loop   // If not, continue loop
<span id="L650" class="ln">   650&nbsp;&nbsp;</span>	CMP     R7, LASTSTR  // Check remainder
<span id="L651" class="ln">   651&nbsp;&nbsp;</span>	BLE     index2to16   // Process remainder
<span id="L652" class="ln">   652&nbsp;&nbsp;</span>	BR      notfound     // Not found
<span id="L653" class="ln">   653&nbsp;&nbsp;</span>
<span id="L654" class="ln">   654&nbsp;&nbsp;</span>index5plus:
<span id="L655" class="ln">   655&nbsp;&nbsp;</span>	CMP R6, $16     // Check for sep &gt; 16
<span id="L656" class="ln">   656&nbsp;&nbsp;</span>	BGT index17plus // Handle large sep
<span id="L657" class="ln">   657&nbsp;&nbsp;</span>
<span id="L658" class="ln">   658&nbsp;&nbsp;</span>	// Assumption is that the separator is smaller than the string at this point
<span id="L659" class="ln">   659&nbsp;&nbsp;</span>index2to16:
<span id="L660" class="ln">   660&nbsp;&nbsp;</span>	CMP R7, LASTSTR // Compare last start byte
<span id="L661" class="ln">   661&nbsp;&nbsp;</span>	BGT notfound    // last takes len(sep) into account
<span id="L662" class="ln">   662&nbsp;&nbsp;</span>
<span id="L663" class="ln">   663&nbsp;&nbsp;</span>	ADD $19, R7, R9    // To check 4 indices per iteration, need at least 16+3 bytes
<span id="L664" class="ln">   664&nbsp;&nbsp;</span>	CMP R9, LASTBYTE
<span id="L665" class="ln">   665&nbsp;&nbsp;</span>	// At least 16 bytes of string left
<span id="L666" class="ln">   666&nbsp;&nbsp;</span>	// Mask the number of bytes in sep
<span id="L667" class="ln">   667&nbsp;&nbsp;</span>	VSPLTISB $0, V10            // Clear
<span id="L668" class="ln">   668&nbsp;&nbsp;</span>	BGT index2to16tail
<span id="L669" class="ln">   669&nbsp;&nbsp;</span>
<span id="L670" class="ln">   670&nbsp;&nbsp;</span>#ifdef GOPPC64_power10
<span id="L671" class="ln">   671&nbsp;&nbsp;</span>	ADD     $3,R7, R17          // Base+3
<span id="L672" class="ln">   672&nbsp;&nbsp;</span>	ADD     $2,R7, R8           // Base+2
<span id="L673" class="ln">   673&nbsp;&nbsp;</span>	ADD     $1,R7, R10          // Base+1
<span id="L674" class="ln">   674&nbsp;&nbsp;</span>#else
<span id="L675" class="ln">   675&nbsp;&nbsp;</span>	MOVD	$3, R17             // Number of bytes beyond 16
<span id="L676" class="ln">   676&nbsp;&nbsp;</span>#endif
<span id="L677" class="ln">   677&nbsp;&nbsp;</span>	PCALIGN  $16
<span id="L678" class="ln">   678&nbsp;&nbsp;</span>
<span id="L679" class="ln">   679&nbsp;&nbsp;</span>index2to16loop:
<span id="L680" class="ln">   680&nbsp;&nbsp;</span>
<span id="L681" class="ln">   681&nbsp;&nbsp;</span>#ifdef GOPPC64_power10
<span id="L682" class="ln">   682&nbsp;&nbsp;</span>	LXVLL  R7, R14, V8          // Load next 16 bytes of string  from Base
<span id="L683" class="ln">   683&nbsp;&nbsp;</span>	LXVLL  R10, R14, V9         // Load next 16 bytes of string from Base+1
<span id="L684" class="ln">   684&nbsp;&nbsp;</span>	LXVLL  R8, R14, V11         // Load next 16 bytes of string from Base+2
<span id="L685" class="ln">   685&nbsp;&nbsp;</span>	LXVLL  R17,R14, V12         // Load next 16 bytes of string  from Base+3
<span id="L686" class="ln">   686&nbsp;&nbsp;</span>#else
<span id="L687" class="ln">   687&nbsp;&nbsp;</span>	LXVB16X  (R7)(R0), V1       // Load next 16 bytes of string into V1 from R7
<span id="L688" class="ln">   688&nbsp;&nbsp;</span>	LXVB16X  (R7)(R17), V5      // Load next 16 bytes of string into V5 from R7+3
<span id="L689" class="ln">   689&nbsp;&nbsp;</span>
<span id="L690" class="ln">   690&nbsp;&nbsp;</span>	VSLDOI   $13, V5, V10, V2  // Shift left last 3 bytes
<span id="L691" class="ln">   691&nbsp;&nbsp;</span>	VSLDOI  $1, V1, V2, V3     // V3=(V1:V2)&lt;&lt;1
<span id="L692" class="ln">   692&nbsp;&nbsp;</span>	VSLDOI  $2, V1, V2, V4     // V4=(V1:V2)&lt;&lt;2
<span id="L693" class="ln">   693&nbsp;&nbsp;</span>	VAND    V1, SEPMASK, V8    // Mask out sep size 0th index
<span id="L694" class="ln">   694&nbsp;&nbsp;</span>	VAND    V3, SEPMASK, V9    // Mask out sep size 1st index
<span id="L695" class="ln">   695&nbsp;&nbsp;</span>	VAND    V4, SEPMASK, V11   // Mask out sep size 2nd index
<span id="L696" class="ln">   696&nbsp;&nbsp;</span>	VAND    V5, SEPMASK, V12   // Mask out sep size 3rd index
<span id="L697" class="ln">   697&nbsp;&nbsp;</span>#endif
<span id="L698" class="ln">   698&nbsp;&nbsp;</span>	VCMPEQUBCC      V0, V8, V8 // compare masked string
<span id="L699" class="ln">   699&nbsp;&nbsp;</span>	BLT     CR6, found         // All equal while comparing 0th index
<span id="L700" class="ln">   700&nbsp;&nbsp;</span>	VCMPEQUBCC      V0, V9, V9 // compare masked string
<span id="L701" class="ln">   701&nbsp;&nbsp;</span>	BLT     CR6, found2        // All equal while comparing 1st index
<span id="L702" class="ln">   702&nbsp;&nbsp;</span>	VCMPEQUBCC      V0, V11, V11    // compare masked string
<span id="L703" class="ln">   703&nbsp;&nbsp;</span>	BLT     CR6, found3        // All equal while comparing 2nd index
<span id="L704" class="ln">   704&nbsp;&nbsp;</span>	VCMPEQUBCC      V0, V12, V12    // compare masked string
<span id="L705" class="ln">   705&nbsp;&nbsp;</span>	BLT     CR6, found4        // All equal while comparing 3rd index
<span id="L706" class="ln">   706&nbsp;&nbsp;</span>
<span id="L707" class="ln">   707&nbsp;&nbsp;</span>	ADD        $4, R7          // Update ptr to next 4 bytes
<span id="L708" class="ln">   708&nbsp;&nbsp;</span>#ifdef GOPPC64_power10
<span id="L709" class="ln">   709&nbsp;&nbsp;</span>	ADD        $4, R17         // Update ptr to next 4 bytes
<span id="L710" class="ln">   710&nbsp;&nbsp;</span>	ADD        $4, R8          // Update ptr to next 4 bytes
<span id="L711" class="ln">   711&nbsp;&nbsp;</span>	ADD        $4, R10         // Update ptr to next 4 bytes
<span id="L712" class="ln">   712&nbsp;&nbsp;</span>#endif
<span id="L713" class="ln">   713&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Still less than last start byte
<span id="L714" class="ln">   714&nbsp;&nbsp;</span>	BGT        notfound        // Not found
<span id="L715" class="ln">   715&nbsp;&nbsp;</span>	ADD        $19, R7, R9     // Verify remaining bytes
<span id="L716" class="ln">   716&nbsp;&nbsp;</span>	CMP        R9, LASTBYTE    // length of string at least 19
<span id="L717" class="ln">   717&nbsp;&nbsp;</span>	BLE        index2to16loop  // Try again, else do post processing and jump to index2to16next
<span id="L718" class="ln">   718&nbsp;&nbsp;</span>	PCALIGN    $32
<span id="L719" class="ln">   719&nbsp;&nbsp;</span>	// &lt;19 bytes left, post process the remaining string
<span id="L720" class="ln">   720&nbsp;&nbsp;</span>index2to16tail:
<span id="L721" class="ln">   721&nbsp;&nbsp;</span>#ifdef GOPPC64_power10
<span id="L722" class="ln">   722&nbsp;&nbsp;</span>index2to16next_p10:
<span id="L723" class="ln">   723&nbsp;&nbsp;</span>	LXVLL   R7,R14, V1       // Load 16 bytes @R7 into V1
<span id="L724" class="ln">   724&nbsp;&nbsp;</span>	VCMPEQUBCC V1, V0, V3      // Compare sep and partial string
<span id="L725" class="ln">   725&nbsp;&nbsp;</span>	BLT        CR6, found      // Found
<span id="L726" class="ln">   726&nbsp;&nbsp;</span>	ADD        $1, R7          // Not found, try next partial string
<span id="L727" class="ln">   727&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check for end of string
<span id="L728" class="ln">   728&nbsp;&nbsp;</span>	BLE        index2to16next_p10        // If at end, then not found
<span id="L729" class="ln">   729&nbsp;&nbsp;</span>	BR         notfound  // go to remainder loop
<span id="L730" class="ln">   730&nbsp;&nbsp;</span>#else
<span id="L731" class="ln">   731&nbsp;&nbsp;</span>	ADD     R3, R4, R9         // End of string
<span id="L732" class="ln">   732&nbsp;&nbsp;</span>	SUB     R7, R9, R9         // Number of bytes left
<span id="L733" class="ln">   733&nbsp;&nbsp;</span>	ANDCC   $15, R7, R10       // 16 byte offset
<span id="L734" class="ln">   734&nbsp;&nbsp;</span>	ADD     R10, R9, R11       // offset + len
<span id="L735" class="ln">   735&nbsp;&nbsp;</span>	CMP     R11, $16           // &gt;= 16?
<span id="L736" class="ln">   736&nbsp;&nbsp;</span>	BLE     short              // Does not cross 16 bytes
<span id="L737" class="ln">   737&nbsp;&nbsp;</span>	LXVB16X (R7)(R0), V1       // Load 16 bytes @R7 into V1
<span id="L738" class="ln">   738&nbsp;&nbsp;</span>	CMP     R9, $16            // Post-processing of unrolled loop
<span id="L739" class="ln">   739&nbsp;&nbsp;</span>	BLE     index2to16next     // continue to index2to16next if &lt;= 16 bytes
<span id="L740" class="ln">   740&nbsp;&nbsp;</span>	SUB     R16, R9, R10       // R9 should be 18 or 17 hence R10 is 1 or 2
<span id="L741" class="ln">   741&nbsp;&nbsp;</span>	LXVB16X (R7)(R10), V9
<span id="L742" class="ln">   742&nbsp;&nbsp;</span>	CMP     R10, $1            // string length is 17, compare 1 more byte
<span id="L743" class="ln">   743&nbsp;&nbsp;</span>	BNE     extra2             // string length is 18, compare 2 more bytes
<span id="L744" class="ln">   744&nbsp;&nbsp;</span>	VSLDOI  $15, V9, V10, V25
<span id="L745" class="ln">   745&nbsp;&nbsp;</span>	VAND       V1, SEPMASK, V2 // Just compare size of sep
<span id="L746" class="ln">   746&nbsp;&nbsp;</span>	VCMPEQUBCC V0, V2, V3      // Compare sep and partial string
<span id="L747" class="ln">   747&nbsp;&nbsp;</span>	BLT        CR6, found      // Found
<span id="L748" class="ln">   748&nbsp;&nbsp;</span>	ADD        $1, R7          // Not found, try next partial string
<span id="L749" class="ln">   749&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check for end of string
<span id="L750" class="ln">   750&nbsp;&nbsp;</span>	BGT        notfound        // If at end, then not found
<span id="L751" class="ln">   751&nbsp;&nbsp;</span>	VSLDOI     $1, V1, V25, V1 // Shift string left by 1 byte
<span id="L752" class="ln">   752&nbsp;&nbsp;</span>	BR         index2to16next  // go to remainder loop
<span id="L753" class="ln">   753&nbsp;&nbsp;</span>extra2:
<span id="L754" class="ln">   754&nbsp;&nbsp;</span>	VSLDOI  $14, V9, V10, V25
<span id="L755" class="ln">   755&nbsp;&nbsp;</span>	VAND       V1, SEPMASK, V2 // Just compare size of sep
<span id="L756" class="ln">   756&nbsp;&nbsp;</span>	VCMPEQUBCC V0, V2, V3      // Compare sep and partial string
<span id="L757" class="ln">   757&nbsp;&nbsp;</span>	BLT        CR6, found      // Found
<span id="L758" class="ln">   758&nbsp;&nbsp;</span>	ADD        $1, R7          // Not found, try next partial string
<span id="L759" class="ln">   759&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check for end of string
<span id="L760" class="ln">   760&nbsp;&nbsp;</span>	BGT        notfound        // If at end, then not found
<span id="L761" class="ln">   761&nbsp;&nbsp;</span>	VOR        V1, V1, V4      // save remaining string
<span id="L762" class="ln">   762&nbsp;&nbsp;</span>	VSLDOI     $1, V1, V25, V1 // Shift string left by 1 byte for 17th byte
<span id="L763" class="ln">   763&nbsp;&nbsp;</span>	VAND       V1, SEPMASK, V2 // Just compare size of sep
<span id="L764" class="ln">   764&nbsp;&nbsp;</span>	VCMPEQUBCC V0, V2, V3      // Compare sep and partial string
<span id="L765" class="ln">   765&nbsp;&nbsp;</span>	BLT        CR6, found      // Found
<span id="L766" class="ln">   766&nbsp;&nbsp;</span>	ADD        $1, R7          // Not found, try next partial string
<span id="L767" class="ln">   767&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check for end of string
<span id="L768" class="ln">   768&nbsp;&nbsp;</span>	BGT        notfound        // If at end, then not found
<span id="L769" class="ln">   769&nbsp;&nbsp;</span>	VSLDOI     $2, V4, V25, V1 // Shift saved string left by 2 bytes for 18th byte
<span id="L770" class="ln">   770&nbsp;&nbsp;</span>	BR         index2to16next  // Check the remaining partial string in index2to16next
<span id="L771" class="ln">   771&nbsp;&nbsp;</span>
<span id="L772" class="ln">   772&nbsp;&nbsp;</span>short:
<span id="L773" class="ln">   773&nbsp;&nbsp;</span>	RLDICR   $0, R7, $59, R9   // Adjust addr to 16 byte container
<span id="L774" class="ln">   774&nbsp;&nbsp;</span>	LXVB16X  (R9)(R0), V1      // Load 16 bytes @R9 into V1
<span id="L775" class="ln">   775&nbsp;&nbsp;</span>	SLD      $3, R10           // Set up shift
<span id="L776" class="ln">   776&nbsp;&nbsp;</span>	MTVSRD   R10, V8           // Set up shift
<span id="L777" class="ln">   777&nbsp;&nbsp;</span>	VSLDOI   $8, V8, V8, V8
<span id="L778" class="ln">   778&nbsp;&nbsp;</span>	VSLO     V1, V8, V1        // Shift by start byte
<span id="L779" class="ln">   779&nbsp;&nbsp;</span>	PCALIGN  $16
<span id="L780" class="ln">   780&nbsp;&nbsp;</span>index2to16next:
<span id="L781" class="ln">   781&nbsp;&nbsp;</span>	VAND       V1, SEPMASK, V2 // Just compare size of sep
<span id="L782" class="ln">   782&nbsp;&nbsp;</span>	VCMPEQUBCC V0, V2, V3      // Compare sep and partial string
<span id="L783" class="ln">   783&nbsp;&nbsp;</span>	BLT        CR6, found      // Found
<span id="L784" class="ln">   784&nbsp;&nbsp;</span>	ADD        $1, R7          // Not found, try next partial string
<span id="L785" class="ln">   785&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check for end of string
<span id="L786" class="ln">   786&nbsp;&nbsp;</span>	BGT        notfound        // If at end, then not found
<span id="L787" class="ln">   787&nbsp;&nbsp;</span>	VSLDOI     $1, V1, V10, V1 // Shift string left by 1 byte
<span id="L788" class="ln">   788&nbsp;&nbsp;</span>	BR         index2to16next  // Check the next partial string
<span id="L789" class="ln">   789&nbsp;&nbsp;</span>#endif // Tail processing if GOPPC64!=power10
<span id="L790" class="ln">   790&nbsp;&nbsp;</span>
<span id="L791" class="ln">   791&nbsp;&nbsp;</span>index17plus:
<span id="L792" class="ln">   792&nbsp;&nbsp;</span>	CMP      R6, $32       // Check if 17 &lt; len(sep) &lt;= 32
<span id="L793" class="ln">   793&nbsp;&nbsp;</span>	BGT      index33plus
<span id="L794" class="ln">   794&nbsp;&nbsp;</span>	SUB      $16, R6, R9   // Extra &gt; 16
<span id="L795" class="ln">   795&nbsp;&nbsp;</span>	SLD      $56, R9, R10  // Shift to use in VSLO
<span id="L796" class="ln">   796&nbsp;&nbsp;</span>	MTVSRD   R10, V9       // Set up for VSLO
<span id="L797" class="ln">   797&nbsp;&nbsp;</span>	LXVB16X  (R5)(R9), V1  // Load 16 bytes @R5+R9 into V1
<span id="L798" class="ln">   798&nbsp;&nbsp;</span>	VSLO     V1, V9, V1    // Shift left
<span id="L799" class="ln">   799&nbsp;&nbsp;</span>	VSPLTISB $0xff, V7     // Splat 1s
<span id="L800" class="ln">   800&nbsp;&nbsp;</span>	VSPLTISB $0, V27       // Splat 0
<span id="L801" class="ln">   801&nbsp;&nbsp;</span>
<span id="L802" class="ln">   802&nbsp;&nbsp;</span>index17to32loop:
<span id="L803" class="ln">   803&nbsp;&nbsp;</span>	LXVB16X (R7)(R0), V2  // Load 16 bytes @R7 into V2
<span id="L804" class="ln">   804&nbsp;&nbsp;</span>
<span id="L805" class="ln">   805&nbsp;&nbsp;</span>next17:
<span id="L806" class="ln">   806&nbsp;&nbsp;</span>	LXVB16X    (R7)(R9), V3    // Load 16 bytes @R7+R9 into V3
<span id="L807" class="ln">   807&nbsp;&nbsp;</span>	VSLO       V3, V9, V3      // Shift left
<span id="L808" class="ln">   808&nbsp;&nbsp;</span>	VCMPEQUB   V0, V2, V4      // Compare first 16 bytes
<span id="L809" class="ln">   809&nbsp;&nbsp;</span>	VCMPEQUB   V1, V3, V5      // Compare extra over 16 bytes
<span id="L810" class="ln">   810&nbsp;&nbsp;</span>	VAND       V4, V5, V6      // Check if both equal
<span id="L811" class="ln">   811&nbsp;&nbsp;</span>	VCMPEQUBCC V6, V7, V8      // All equal?
<span id="L812" class="ln">   812&nbsp;&nbsp;</span>	BLT        CR6, found      // Yes
<span id="L813" class="ln">   813&nbsp;&nbsp;</span>	ADD        $1, R7          // On to next byte
<span id="L814" class="ln">   814&nbsp;&nbsp;</span>	CMP        R7, LASTSTR     // Check if last start byte
<span id="L815" class="ln">   815&nbsp;&nbsp;</span>	BGT        notfound        // If too high, not found
<span id="L816" class="ln">   816&nbsp;&nbsp;</span>	BR         index17to32loop // Continue
<span id="L817" class="ln">   817&nbsp;&nbsp;</span>
<span id="L818" class="ln">   818&nbsp;&nbsp;</span>notfound:
<span id="L819" class="ln">   819&nbsp;&nbsp;</span>	MOVD $-1, R3   // Return -1 if not found
<span id="L820" class="ln">   820&nbsp;&nbsp;</span>	RET
<span id="L821" class="ln">   821&nbsp;&nbsp;</span>
<span id="L822" class="ln">   822&nbsp;&nbsp;</span>index33plus:
<span id="L823" class="ln">   823&nbsp;&nbsp;</span>	MOVD $0, (R0) // Case not implemented
<span id="L824" class="ln">   824&nbsp;&nbsp;</span>	RET           // Crash before return
<span id="L825" class="ln">   825&nbsp;&nbsp;</span>
<span id="L826" class="ln">   826&nbsp;&nbsp;</span>foundR25:
<span id="L827" class="ln">   827&nbsp;&nbsp;</span>	SRD  $3, R25   // Convert from bits to bytes
<span id="L828" class="ln">   828&nbsp;&nbsp;</span>	ADD  R25, R7   // Add to current string address
<span id="L829" class="ln">   829&nbsp;&nbsp;</span>	SUB  R3, R7    // Subtract from start of string
<span id="L830" class="ln">   830&nbsp;&nbsp;</span>	MOVD R7, R3    // Return byte where found
<span id="L831" class="ln">   831&nbsp;&nbsp;</span>	RET
<span id="L832" class="ln">   832&nbsp;&nbsp;</span>found4:
<span id="L833" class="ln">   833&nbsp;&nbsp;</span>	ADD $1, R7     // found from unrolled loop at index 3
<span id="L834" class="ln">   834&nbsp;&nbsp;</span>found3:
<span id="L835" class="ln">   835&nbsp;&nbsp;</span>	ADD $1, R7     // found from unrolled loop at index 2
<span id="L836" class="ln">   836&nbsp;&nbsp;</span>found2:
<span id="L837" class="ln">   837&nbsp;&nbsp;</span>	ADD $1, R7     // found from unrolled loop at index 1
<span id="L838" class="ln">   838&nbsp;&nbsp;</span>found:                 // found at index 0
<span id="L839" class="ln">   839&nbsp;&nbsp;</span>	SUB  R3, R7    // Return byte where found
<span id="L840" class="ln">   840&nbsp;&nbsp;</span>	MOVD R7, R3
<span id="L841" class="ln">   841&nbsp;&nbsp;</span>	RET
<span id="L842" class="ln">   842&nbsp;&nbsp;</span>
</pre><p><a href="/src/internal/bytealg/index_ppc64x.s?m=text">View as plain text</a></p>

</article>

</main>
<footer class="Site-footer">
  <div class="Footer">
    <div class="Container">
      <div class="Footer-links">
          <div class="Footer-linkColumn">
            <a href="/solutions/" class="Footer-link Footer-link--primary" aria-describedby="footer-description">
              Tại sao Go
            </a>
              <a href="/solutions/use-cases" class="Footer-link" aria-describedby="footer-description">
                Use Cases
              </a>
              <a href="/solutions/case-studies" class="Footer-link" aria-describedby="footer-description">
                Case Studies
              </a>
          </div>
          <div class="Footer-linkColumn">
            <a href="/learn/" class="Footer-link Footer-link--primary" aria-describedby="footer-description">
              Bắt đầu
            </a>
              <a href="/play" class="Footer-link" aria-describedby="footer-description">
                Playground
              </a>
              <a href="/tour/" class="Footer-link" aria-describedby="footer-description">
                Tour
              </a>
              <a href="https://stackoverflow.com/questions/tagged/go?tab=Newest" class="Footer-link" aria-describedby="footer-description">
                Stack Overflow
              </a>
              <a href="/help/" class="Footer-link" aria-describedby="footer-description">
                Trợ giúp
              </a>
          </div>
          <div class="Footer-linkColumn">
            <a href="https://pkg.go.dev" class="Footer-link Footer-link--primary" aria-describedby="footer-description">
              Packages
            </a>
              <a href="/pkg/" class="Footer-link" aria-describedby="footer-description">
                Thư viện chuẩn
              </a>
              <a href="https://pkg.go.dev/about" class="Footer-link" aria-describedby="footer-description">
                Giới thiệu về Go Packages
              </a>
          </div>
          <div class="Footer-linkColumn">
            <a href="/project" class="Footer-link Footer-link--primary" aria-describedby="footer-description">
              Giới thiệu
            </a>
              <a href="/dl/" class="Footer-link" aria-describedby="footer-description">
                Tải xuống
              </a>
              <a href="/blog/" class="Footer-link" aria-describedby="footer-description">
                Blog
              </a>
              <a href="https://github.com/golang/go/issues" class="Footer-link" aria-describedby="footer-description">
                Issue Tracker
              </a>
              <a href="/doc/devel/release" class="Footer-link" aria-describedby="footer-description">
                Ghi chú bản phát hành
              </a>
              <a href="/brand" class="Footer-link" aria-describedby="footer-description">
                Hướng dẫn thương hiệu
              </a>
              <a href="/conduct" class="Footer-link" aria-describedby="footer-description">
                Quy tắc ứng xử
              </a>
          </div>
          <div class="Footer-linkColumn">
            <a href="/wiki/#the-go-community" class="Footer-link Footer-link--primary" aria-describedby="footer-description">
              Kết nối
            </a>
              <a href="https://bsky.app/profile/golang.org" class="Footer-link" aria-describedby="footer-description">
                Bluesky
              </a>
              <a href="https://hachyderm.io/@golang" class="Footer-link" aria-describedby="footer-description">
                Mastodon
              </a>
              <a href="https://www.twitter.com/golang" class="Footer-link" aria-describedby="footer-description">
                Twitter
              </a>
              <a href="https://github.com/golang" class="Footer-link" aria-describedby="footer-description">
                GitHub
              </a>
              <a href="https://invite.slack.golangbridge.org/" class="Footer-link" aria-describedby="footer-description">
                Slack
              </a>
              <a href="https://reddit.com/r/golang" class="Footer-link" aria-describedby="footer-description">
                r/golang
              </a>
              <a href="https://www.meetup.com/pro/go" class="Footer-link" aria-describedby="footer-description">
                Meetup
              </a>
              <a href="https://golangweekly.com/" class="Footer-link" aria-describedby="footer-description">
                Golang Weekly
              </a>
          </div>
      </div>
    </div>
  </div>
  <div class="screen-reader-only" id="footer-description" hidden>
          Mở trong cửa sổ mới.
  </div>
  <div class="Footer">
    <div class="Container Container--fullBleed">
      <div class="Footer-bottom">
        <img class="Footer-gopher" src="/images/gophers/pilot-bust.svg" alt="Go Gopher">
        <ul class="Footer-listRow">
          <li class="Footer-listItem">
            <a href="/copyright" aria-describedby="footer-description">Bản quyền</a>
          </li>
          <li class="Footer-listItem">
            <a href="/tos" aria-describedby="footer-description">Điều khoản dịch vụ</a>
          </li>
          <li class="Footer-listItem">
            <a href="http://www.google.com/intl/en/policies/privacy/" aria-describedby="footer-description"
              target="_blank"
              rel="noopener">
              Chính sách quyền riêng tư
            </a>
            </li>
          <li class="Footer-listItem">
            <a
              href="/s/website-issue" aria-describedby="footer-description"
              target="_blank"
              rel="noopener"
              >
              Báo cáo sự cố
            </a>
          </li>
          <li class="Footer-listItem go-Footer-listItem">
            <button class="go-Button go-Button--text go-Footer-toggleTheme js-toggleTheme" aria-label="Chuyển đổi giao diện">
              <img
                data-value="auto"
                class="go-Icon go-Icon--inverted"
                height="24"
                width="24"
                src="/images/icons/brightness_6_gm_grey_24dp.svg"
                alt="Giao diện hệ thống">
              <img
                data-value="dark"
                class="go-Icon go-Icon--inverted"
                height="24"
                width="24"
                src="/images/icons/brightness_2_gm_grey_24dp.svg"
                alt="Giao diện tối">
              <img
                data-value="light"
                class="go-Icon go-Icon--inverted"
                height="24"
                width="24"
                src="/images/icons/light_mode_gm_grey_24dp.svg"
                alt="Giao diện sáng">
            </button>
          </li>
        </ul>
        <a class="Footer-googleLogo" target="_blank" href="https://google.com" rel="noopener">
          <img class="Footer-googleLogoImg" src="/images/google-white.png" alt="Logo Google">
        </a>
      </div>
    </div>
  </div>
  <script src="/js/jquery.js"></script>
  <script src="/js/carousels.js"></script>
  <script src="/js/searchBox.js"></script>
  <script src="/js/misc.js"></script>
  <script src="/js/hats.js"></script>
  <script src="/js/playground.js"></script>
  <script src="/js/godocs.js"></script>
  <script async src="/js/copypaste.js"></script>
</footer>
<section class="Cookie-notice js-cookieNotice">
  <div>go.dev sử dụng cookie của Google để cung cấp và nâng cao chất lượng dịch vụ cũng như
  phân tích lưu lượng truy cập. <a target=_blank href="https://policies.google.com/technologies/cookies">Tìm hiểu thêm.</a></div>
  <div><button class="go-Button">Đồng ý</button></div>
</section>
</body>
</html>


















