<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><br><hr id="zwchr"><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>From: </b>"Adam Nemet" <anemet@apple.com><br><b>To: </b>"Hal Finkel" <hfinkel@anl.gov><br><b>Cc: </b>reviews+D7421+public+86df0334cf13545b@reviews.llvm.org, "llvm-commits" <llvm-commits@cs.uiuc.edu>, "Nadav Rotem <nrotem@apple.com> (nrotem@apple.com)" <nrotem@apple.com>, "Arnold Schwaighofer" <aschwaighofer@apple.com>, chandlerc@gmail.com<br><b>Sent: </b>Wednesday, February 4, 2015 10:04:54 PM<br><b>Subject: </b>Re: [PATCH] IRBuilder: Allow retrieval of the inserted instructions<br><br>
<br class=""><div><blockquote class=""><div class="">On Feb 4, 2015, at 6:14 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class=""><hr id="zwchr"></span><br style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">From: "Adam Nemet" <<a href="mailto:anemet@apple.com" class="" target="_blank">anemet@apple.com</a>><br class="">To: <a href="mailto:anemet@apple.com" class="" target="_blank">anemet@apple.com</a>, <a href="mailto:hfinkel@anl.gov" class="" target="_blank">hfinkel@anl.gov</a>, <a href="mailto:nrotem@apple.com" class="" target="_blank">nrotem@apple.com</a>, <a href="mailto:aschwaighofer@apple.com" class="" target="_blank">aschwaighofer@apple.com</a>, <a href="mailto:chandlerc@gmail.com" class="" target="_blank">chandlerc@gmail.com</a><br class="">Cc: <a href="mailto:llvm-commits@cs.uiuc.edu" class="" target="_blank">llvm-commits@cs.uiuc.edu</a><br class="">Sent: Wednesday, February 4, 2015 5:58:45 PM<br class="">Subject: [PATCH] IRBuilder: Allow retrieval of the inserted instructions<br class=""><br class="">Hi hfinkel, nadav, aschwaighofer, chandlerc,<br class=""><br class="">This is an RFC.<br class=""><br class="">When the Loop Vectorizer builds the instruction sequence for checks<br class="">it tries<br class="">to determine the first instruction that was emitted in the current<br class="">block.<br class="">This is then used to split the block.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">Silly question: Why don't we split the block first?</span><br style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""></div></blockquote><div><br class=""></div><div id="DWT22676">Because we may end up not needing any checks in which case we don’t split.  The decision of whether checks are necessary is local to both addRuntimeCheck and addStrideCheck.</div></div></blockquote><br>Okay, but an alternative design would be to always split early, and then let SimplifyCFG put them back together again should we not actually end up with any checks, right? I'm not necessarily advocating for this approach, and think that the marker code will be cleaner than the existing getFirstInst code, but splitting the block eagerly will also create a trivial way of marking that point, and I want to understand if there are any downsides to that approach before we invent something new.<br><br>Thanks again,<br>Hal<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div><div></div><div><br class=""></div><div>Adam    </div><br class=""><blockquote class=""><div class=""><span style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">-Hal</span><br style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><blockquote style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><br class="">It uses a custom solution for this implemented in the static function<br class="">getFirstInst.  The pattern is something like:<br class=""><br class="">Value *V = IRBuilder.CreateBlah(...);<br class="">FirstInst = getFirstInst(FirstInst, V, Loc)<br class="">Value *V2 = IRBuilder.CreateBlah(...);<br class="">FirstInst = getFirstInst(FirstInst, V2, Loc);<br class=""><br class="">(Since CreateBlah may return a constant we may not generate the first<br class="">instruction for V.)<br class=""><br><span style="font-family: Helvetica; font-size: 10px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class=""></span></blockquote></div></blockquote></div><br class=""></blockquote><br><br><br>-- <br><div><span name="x"></span>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory<span name="x"></span><br></div></div></body></html>