Yes, it would.<div><br></div><div>But I was concerned Micah was just going to write it off as an implementation detail, so I felt that I should offer a "less correct but less work" option for him to consider.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>James<br><br><div class="gmail_quote">On 29 September 2012 03:16, Owen Anderson <span dir="ltr"><<a href="mailto:resistor@mac.com" target="_blank">resistor@mac.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="im"><br><div><div>On Sep 28, 2012, at 9:45 AM, James Molloy <<a href="mailto:james@jamesmolloy.co.uk" target="_blank">james@jamesmolloy.co.uk</a>> wrote:</div>
<br><blockquote type="cite"><span style="font-family:Helvetica;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none">You can easily simplify this problem with a restriction in SPIR: disallow ConstantExpr casts - no ptrtoint constant expression. Because GlobalVariables have pointer type, if you disallow converting their type to non-pointer type in a constantexpr, the number of constantexpr subclasses you have to deal with is drastically reduced (to essentially just BitCast and GEP).</span></blockquote>
</div><br></div><div>Wouldn't an easier solution just be not to represent them as constants in the first place?  For instance, you could have a built-in function to get the address of local N, where N is taken as a parameter.  You can call the builtins at the beginning of the kernel, and then proceed to use them as you wish without having to worry about reversing a constant folding later.  Plus, if a given vendor's backend <i>wants</i> the address to get constant folded, it's easy to do replaceAllUsesWith of the call with a global, and run an appropriate constant folding pass.</div>
<span class="HOEnZb"><font color="#888888"><div><br></div><div>--Owen</div></font></span></div></blockquote></div><br></div>