<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:16px"><div id="yui_3_16_0_1_1429764735415_7785">Thank you Sanjoy for the explanation. Is it worth filing a bug over this at this point?</div><div id="yui_3_16_0_1_1429764735415_8638"><br></div><div dir="ltr" id="yui_3_16_0_1_1429764735415_8639">Hi James,</div><div id="yui_3_16_0_1_1429764735415_8789" dir="ltr">>Your first example is similar to the strided loops that Hao is working on vectorizing with his indexed load intrinsics.</div><div id="yui_3_16_0_1_1429764735415_10599" dir="ltr">I'm curious. For the example I mentioned, legality check fails because the corresponding SCEV doesn't have nsw set and hence isStridedPtr() returns false. In reality the induction variable has a statically known bound and it cannot overflow, so it is really legal to vectorize the loop. Did you face this problem (and solve it) ?</div><div dir="ltr"><br></div><div id="yui_3_16_0_1_1429764735415_16692" dir="ltr">Thanks everyone for your response and clarification.<br></div><div id="yui_3_16_0_1_1429764735415_7784"><br></div><div id="yui_3_16_0_1_1429764735415_9725"><br></div><div><span></span></div><div> </div><div><div>- Vaivaswatha</div></div>  <br><div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif; font-size: 16px;"> <div dir="ltr"> <font size="2" face="Arial"> On Thursday, 23 April 2015 12:22 AM, Sanjoy Das <sanjoy@playingwithpointers.com> wrote:<br> </font> </div>  <br><br> <div class="y_msg_container">> I expect SCEV treats them differently because of MAX_INT handling.<br clear="none">> Look as the definedness of both if n == MAX_INT. The first has<br clear="none">> undefined behavior, the second does not.<br clear="none">> If you change the second into the first, you introduce undefined behavior.<br clear="none">> (or maybe it's implementation defined, but whatever)<br clear="none"><br clear="none">To elaborate a little further on this:<br clear="none"><br clear="none">In the first loop, you can never enter the loop with "j == INT_SMAX"<br clear="none">since INT_SMAX will never be < anything.  This means j + 1 cannot<br clear="none">overflow.  In the second loop you /can/ enter the loop with "j ==<br clear="none">INT_SMAX" if "n == INT_SMAX" so j + 1 can potentially overflow.<br clear="none"><br clear="none">Ideally SCEV should be able to infer the nsw'ness of the additions<br clear="none">from the nsw bits in the source IR; but that's more complex that it<br clear="none">sounds since SCEV does not have  a notion of control flow within the<br clear="none">loop and it hashes SCEVs by the operands and not by the nsw/nuw bits.<br clear="none">Crude example:<br clear="none"><br clear="none">define void @x(i32 %a, i32 %b, i1 %c) {<br clear="none"> entry:<br clear="none">  %m = add i32 %a, %b<br clear="none">  br i1 %c, label %do, label %dont<br clear="none"><br clear="none"> do:<br clear="none">  %m1 = add nsw i32 %a, %b<br clear="none">  br label %dont<br clear="none"><br clear="none"> dont:<br clear="none">  ret void<br clear="none">}<br clear="none"><br clear="none">both %m and %m1 get mapped to the *same* SCEV, and you cannot mark<br clear="none">that SCEV as nsw even though %m1 is nsw.<br clear="none"><br clear="none">-- Sanjoy<div class="yqt6620045738" id="yqtfd13982"><br clear="none"><br clear="none"><br clear="none"><br clear="none">><br clear="none">><br clear="none">> This is the:<br clear="none">>   if (!getUnsignedRange(RHS).getUnsignedMax().isMaxValue()) {<br clear="none">><br clear="none">> check in that function simplify.<br clear="none">><br clear="none">> But you should file a bug anyway.</div><br clear="none">> _______________________________________________<br clear="none">> LLVM Developers mailing list<br clear="none">> <a shape="rect" ymailto="mailto:LLVMdev@cs.uiuc.edu" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a shape="rect" href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br clear="none">> <a shape="rect" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><div class="yqt6620045738" id="yqtfd26591"><br clear="none"></div><br><br></div>  </div> </div>  </div></div></body></html>