<div dir="ltr">Hi David, <div><br></div><div>The thread you cited is talking about DAGTypeLegalizer::isTypeLegal which looks separate from DataLayout::isLegalInteger we've been talking about here. Maybe LLVM assumes they should be consistent? <div><br></div><div>I see two approaches here. </div><div><br></div><div>1. Making 64-bit illegal in NVPTX's data layout. This will solve the problem this patch originates from, because ShouldChangeType already disallows conversion to data-layout-illegal types. I also suspect this won't break the codegen, because DAGTypeLegalizer still considers 64-bit a legal type and is able to emit 64-bit PTX instructions such as add.s64. However, this will cause performance issues in LSR (which is being discussed in Bjarke's thread <a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/087234.html">http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/087234.html</a>) and maybe other passes. Currently, LSR only promotes variables with legal bitwidths to indvars. Pointers in NVPTX64 are 64-bit so LSR, so LSR won't consider them at all. Therefore, if we make 64-bit data-layout-illegal, we will have to fix some callers of DataLayout::isLegalInteger to handle non-native integer/pointer types (using TTI's instruction cost model e.g.) to get good performance. </div><div><br></div><div>2. (the approach taken in this patch) Keeping 64-bit legal in NVPTX's data layout, and let the callers of isLegalInteger (InstCombineCasts in this case) be aware of cost difference in legal types. </div><div><br></div><div>I don't see a clear winner. Should 64-bit be legal or illegal in NVPTX's data layout? NVPTX emits PTX ISA in which 64-bit is native, but 64-bit in not native in the more low-level machine code. Any thoughts? </div><div><br></div><div>Jingyue</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 1, 2015 at 11:44 AM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Jun 30, 2015 at 9:34 AM, Justin Holewinski <span dir="ltr"><<a href="mailto:jholewinski@nvidia.com" target="_blank">jholewinski@nvidia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><br>
> On Jun 26, 2015, at 4:20 AM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>> wrote:<br>
><br>
> This doesn't seem like the right approach at all.<br>
><br>
> I don't think we want to use cost heuristics to dictate the canonical form in the IR. It makes the canonicalization *much* more complex and hard to manage.<br>
<br>
</span>I agree.  I would prefer not to mix the concepts of legality and performance here.<br>
<br>
><br>
> I think that NVPTX should either change the datalayout to make i64 illegal (and that seems reasonable for instcombine to respect, but that would for example mean it would be an *absolute* decision, not a cost decision) or you'll need to do a late transform to narrow the operations as much as possible.<br>
<br>
I don’t see how we could remove i64 as a legal type in NVPTX.  Our pointer size is 64-bit, so we need a container for pointers.<br></blockquote><div><br></div></span><div>I think other folks are doing (or would like to be doing) this sort of thing: <a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/087248.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/087248.html</a></div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span><br>
><br>
><br>
> <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10750&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=HHEi_oYiSDkf5EvP4msETNSGVoo4vZs4T8UbR8xB5Hg&s=cowKRYmfmrRtHgQktSA7g96aGrml9nEoTTol068qP7o&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/D10750</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=HHEi_oYiSDkf5EvP4msETNSGVoo4vZs4T8UbR8xB5Hg&s=CEmTgNLrWuSwm2G4jfB3s05CpUIDI3LOZdiH5GKCiJc&e=" rel="noreferrer" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
><br>
><br>
<br>
<br>
</span>-----------------------------------------------------------------------------------<br>
This email message is for the sole use of the intended recipient(s) and may contain<br>
confidential information.  Any unauthorized review, use, disclosure or distribution<br>
is prohibited.  If you are not the intended recipient, please contact the sender by<br>
reply email and destroy all copies of the original message.<br>
-----------------------------------------------------------------------------------<br>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div>