<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>"Mehdi Amini via llvm-dev" <llvm-dev@lists.llvm.org><br><b>To: </b>"Shixiong Xu" <shixiong@cadence.com><br><b>Cc: </b>llvm-dev@lists.llvm.org<br><b>Sent: </b>Thursday, August 18, 2016 11:05:35 AM<br><b>Subject: </b>Re: [llvm-dev] Cost model is missing in InstCombiner<br><br>
+David M.<div class=""><br class=""></div><div class=""><br class=""><div><blockquote class=""><div class="">On Aug 17, 2016, at 3:48 AM, Shixiong Xu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="" target="_blank">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-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">Hi,</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""> </div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">I think canEvaluateTruncated() in InstCombiner needs use cost model to decide whether perform optimization or not.</div></div></div></blockquote><div><br class=""></div><div id="DWT1942">I’ve always seen InstCombine as doing “canonicalization” of the IR and not “optimization”. So the output of InstCombine should be in a form that is the most suitable for further analyses and transformations.</div></div></div></blockquote>This is exactly our traditional view. Why can the backend not be fixed to generate better code for mul <32 x i8>? It looks like the widening in the IR is something natural to get from legalization (if you set up the correct promotion preferences in *ISelLowering).<br><br> -Hal<br><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 class=""><div><div></div><div>I’m not sure how this view fits with TTI, I may not be incompatible if used within some limits I guess?</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><br class=""><blockquote class=""><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">  Without cost model from TargetTransformInfo, aggressively optimizing IR in vector types according to the number of bits demanded may lead to scalarization of vector operations. For example, if the input IR is:</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""> </div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">  %wide.load25 = load <32 x i8>, <32 x i8>* %231, align 1</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">  %232 = zext <32 x i8> %wide.load25 to <32 x i16></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">  %233 = mul nuw nsw <32 x i16> %232, %164</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">  …</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">  %237 = trunc <32 x i16> %233 to <32 x i8></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">  store <32 x i8> %237, <32 x i8>* %236, align 1</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""> </div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">ICE: EvaluateInDifferentType converting expression type to avoid cast:   %9 = trunc <32 x i16> %6 to <32 x i8></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">IC: ADD:   %6 = mul <32 x i8> %wide.load25, %wide.load</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">IC: Replacing   %10 = trunc <32 x i16> %7 to <32 x i8></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">    with   %6 = mul <32 x i8> %wide.load25, %wide.load</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""> </div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class="">If the target doesn’t have support for mul <32 x i8>, the inst combiner will yield less profitable code.</div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""> </div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""><span class="" lang="EN-IE">Cheers,</span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""><span class="" lang="EN-IE"> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""><span class="" lang="EN-IE">Shixiong (Jason) Xu</span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri,sans-serif;" class=""> </div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; float: none; display: inline ! important;" class="">LLVM Developers mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><a 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-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="" target="_blank">llvm-dev@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><a 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-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div></blockquote></div><br class=""></div><br>_______________________________________________<br>LLVM Developers mailing list<br>llvm-dev@lists.llvm.org<br>http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br></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>