<div dir="ltr">Makes sense. Thank you! </div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 20, 2015 at 9:25 AM, <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">================<br>
Comment at: include/llvm/Analysis/TargetTransformInfoImpl.h:392<br>
@@ +391,3 @@<br>
+ unsigned getGEPCost(const Value *Ptr, ArrayRef<Value *> Operands) {<br>
+ const GlobalValue *BaseGV = dyn_cast<GlobalValue>(Ptr);<br>
+ bool HasBaseReg = (BaseGV == nullptr);<br>
----------------<br>
</span><span class="">jingyue wrote:<br>
> hfinkel wrote:<br>
> > hfinkel wrote:<br>
> > > You should call stripPointerCasts before doing the dyn_cast.<br>
> > Should be dyn_cast_or_null b/c the cost model should not require the base pointer be known when estimating costs.<br>
> Interesting -- when Ptr == nullptr, what is a good estimation? Fall back to using `getAddressComputationCost`?<br>
</span>No, but there is another issue here. We're currently moving to give pointer an opaque type, and so you'll need to separately require a Type* on this interface. Please add that. Once you have the Type *, you should:<br>
<br>
1. assert that the type is equal to the pointer element type of the provided pointer (if it is provided) -- we'll remove this once we actually get rid of pointer element types, but for now we need the asserts<br>
2. use that type in the code below (there is a getGEPReturnType overload that takes the element type instead of the pointer itself)<br>
3. Make some default assumption for HasBaseReg (I think you should assume true).<br>
<div class="HOEnZb"><div class="h5"><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D9819&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pjuzBDUwXRv4QLGCRIgVNBCHcpUKMUhfWB7I59hHqHo&s=onPmylFLdkBWySHyc1WRyuASC37sjDaFMX5jSic62D0&e=" target="_blank">http://reviews.llvm.org/D9819</a><br>
<br>
EMAIL PREFERENCES<br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_settings_panel_emailpreferences_&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=pjuzBDUwXRv4QLGCRIgVNBCHcpUKMUhfWB7I59hHqHo&s=xwfXHLhTf8P3kwG4Lcw3jypQeLsRAY-lTBdsPza-Zrg&e=" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<br>
</div></div></blockquote></div><br></div>