<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 24, 2008, at 4:46 PM, Wojciech Matyjewicz wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><blockquote type="cite">I asked myself the same question. Without mod, how do you ensure that for instance the expression 2*i+255 was not actually 2*i-1 ?<br></blockquote><br>I think it is not possible in general, but I believe it is possible in<br>case of affine expressions used as GEP indices.<br><br>I assume, GEP indices (except indexing into struct) are interpreted as<br>signed integers. It isn't explicitly stated in the LangRef, but the code<br>seems to treat them this way. Am I correct?<br><br>If the result of an affine expression:<br> a_1*i_1 + a_2*i_2 + ... + a_n*i_n<br>is interpreted as signed value during the program run, it should be safe<br>to assume during the program analysis that all operations (coefficients)<br>are signed - signed evaluation of such an expression will bring the same<br>result as evaluation of the expression using original signedness and<br>interpretation of the produced value as signed. </div></blockquote><div><br></div><div><br></div><div>That sounds correct to me.</div><div><br></div><div><br></div><br><blockquote type="cite"><div>However, such an<br>assumption requires that arbitrary precise arithmetic is used during the<br>program analysis. Otherwise, a signed overflow (undefined in LLVM) might<br>be introduced that does not appear during the program run.</div></blockquote><div><br></div>I think you can do this without true arbitrary precision arithmetic, but just a few careful checks for overflow in the compiler.</div><div><br></div><div><br><blockquote type="cite"><div><br><br>-Wojtek<br></div></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div><div><div><div><br><br></div><div>--Vikram</div><div><i><a href="http://www.cs.uiuc.edu/~vadve">http://www.cs.uiuc.edu/~vadve</a></i></div><div><i><a href="http://llvm.org/">http://llvm.org/</a></i></div><br><br></div></div></div></div></div></div></span></div></span></div></span> </div><br></body></html>