<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><br>
</p>
<div class="moz-cite-prefix">On 02/22/2017 11:52 AM, Adam Nemet via
llvm-dev wrote:<br>
</div>
<blockquote
cite="mid:16F14A70-9DE7-4057-A308-040C18B1637E@apple.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div class="">Hi Ashutosh,</div>
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Feb 22, 2017, at 1:57 AM, Nema, Ashutosh via
llvm-dev <<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1;
font-family: Helvetica; font-size: 12px; font-style:
normal; font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Hi,<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">This is a proposal
about epilog loop vectorization.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Currently Loop
Vectorizer inserts an epilogue loop for handling loops
that don’t have known iteration counts.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">The Loop Vectorizer
supports loops with an unknown trip count, unknown
trip count may not be a multiple of the vector width,
and the vectorizer has to execute the last few
iterations as scalar code. It keeps a scalar copy of
the loop for the remaining iterations.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Loop with the large
width has a high possibility of executing many scalar
iterations.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">i.e. i8 data type
with 256bits target register can vectorize with vector
width 32, with that maximum trip count possibility for
scalar(epilog) loop is 31, which is significant &
worth vectorizing.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Large vector factor
has following challenges:<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt 0.5in; font-size:
11pt; font-family: Calibri, sans-serif; text-indent:
-0.25in;" class=""><span style="font-family: 'Lucida
Sans Unicode', sans-serif;" class=""><span class="">1)<span
style="font-style: normal; font-variant-caps:
normal; font-weight: normal; font-size: 7pt;
line-height: normal; font-family: 'Times New
Roman';" class=""> <span
class="Apple-converted-space"> </span></span></span></span><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Possibility of
remainder iteration is substantial.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt 0.5in; font-size:
11pt; font-family: Calibri, sans-serif; text-indent:
-0.25in;" class=""><span style="font-family: 'Lucida
Sans Unicode', sans-serif;" class=""><span class="">2)<span
style="font-style: normal; font-variant-caps:
normal; font-weight: normal; font-size: 7pt;
line-height: normal; font-family: 'Times New
Roman';" class=""> <span
class="Apple-converted-space"> </span></span></span></span><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Actual trip count
at runtime is substantial but not meeting minimum trip
count to execute vector loop.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">These challenges
can be addressed by mask instructions, but these
instructions are limited and may not be available to
all targets.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">By epilog
vectorization our aim to vectorize epilog loop where
original loop is vectorized with large vector factor
and has a high possibility of executing scalar
iterations.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">This require
following changes:<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt 0.5in; font-size:
11pt; font-family: Calibri, sans-serif; text-indent:
-0.25in;" class=""><span style="font-family: 'Lucida
Sans Unicode', sans-serif;" class=""><span class="">1)<span
style="font-style: normal; font-variant-caps:
normal; font-weight: normal; font-size: 7pt;
line-height: normal; font-family: 'Times New
Roman';" class=""> <span
class="Apple-converted-space"> </span></span></span></span><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Costing: Preserve
all profitable vector factor.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt 0.5in; font-size:
11pt; font-family: Calibri, sans-serif; text-indent:
-0.25in;" class=""><span style="font-family: 'Lucida
Sans Unicode', sans-serif;" class=""><span class="">2)<span
style="font-style: normal; font-variant-caps:
normal; font-weight: normal; font-size: 7pt;
line-height: normal; font-family: 'Times New
Roman';" class=""> <span
class="Apple-converted-space"> </span></span></span></span><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Transform: Create
an additional vector loop with next profitable vector
factor.</span></div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>Is this something that you propose to be on by default for
wide VPU architectures without masking support? I.e. how
widely is this applicable? If not then perhaps a better
strategy would be to just annotate the remainder loop with
some metadata to limit the vectorization factor and just rerun
the vectorizer.</div>
</div>
</blockquote>
<br>
Why would this solution (annotating the remainder loop to limit
vectorization and rerunning the vectorization process) not be
preferred regardless?<br>
<br>
One issue that might be relevant here are runtime aliasing checks,
which are probably going to be redundant, or partially redundant,
between the different vectorized versions. Will we be able to do any
necessary cleanup after the fact? Moreover, we often don't hoist
(unswitch) these checks out of inner loops (perhaps because they're
inside the trip-count checks?); I wonder if the proposed block
structure will make this situation better or worse (or have no
overall effect).<br>
<br>
Thanks again,<br>
Hal<br>
<br>
<blockquote
cite="mid:16F14A70-9DE7-4057-A308-040C18B1637E@apple.com"
type="cite">
<div>
<div><br class="">
</div>
<div>Adam</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div class="WordSection1" style="page: WordSection1;
font-family: Helvetica; font-size: 12px; font-style:
normal; font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-stroke-width: 0px;">
<div style="margin: 0in 0in 0.0001pt 0.5in; font-size:
11pt; font-family: Calibri, sans-serif; text-indent:
-0.25in;" class=""><span style="font-family: 'Lucida
Sans Unicode', sans-serif; background-color: white;"
class=""><o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Please refer
attached file (BlockLayout.png) for the details about
transformed block layout.<o:p class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Patch is available
at:<span class="Apple-converted-space"> </span><a
moz-do-not-send="true"
href="https://reviews.llvm.org/D30247" style="color:
rgb(149, 79, 114); text-decoration: underline;"
class="">https://reviews.llvm.org/D30247</a><o:p
class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Regards,<o:p
class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><span
style="font-family: 'Lucida Sans Unicode', sans-serif;
background-color: white;" class="">Ashutosh<o:p
class=""></o:p></span></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt;
font-family: Calibri, sans-serif;" class=""><o:p
class=""> </o:p></div>
</div>
<span
id="cid:770D11B0-E822-4799-8A56-411EB81EBD02@apple.com"><BlockLayout.png></span><span
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none; display:
inline !important;" class="">_______________________________________________</span><br
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px; float: none; display:
inline !important;" class="">LLVM Developers mailing list</span><br
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<a moz-do-not-send="true"
href="mailto:llvm-dev@lists.llvm.org" style="color:
rgb(149, 79, 114); text-decoration: underline;
font-family: Helvetica; font-size: 12px; font-style:
normal; font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px;" class="">llvm-dev@lists.llvm.org</a><br
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-stroke-width: 0px;" class="">
<a moz-do-not-send="true"
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
style="color: rgb(149, 79, 114); text-decoration:
underline; font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
</blockquote>
</div>
<br class="">
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>