<div dir="ltr"><div class="markdown-here-wrapper" style=""><blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:1.2em 0px!important">I think your proposed solution is a bit of overkill for this problem, because<br>it impacts legalization of all SDNodes, when only a few are actually used<br>for pointer arithmetic.</p>
</blockquote>
<p style="margin:1.2em 0px!important">I agree with you. I do however think that it has its advantages.</p>
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:1.2em 0px!important">It seems like there are some out of tree patches for handling illegal<br>pointer types. Maybe you can work with David to get these changes<br>upstream.</p>
</blockquote>
<p style="margin:1.2em 0px!important">There are a few out of tree patches, but they all work around the problem at hand.<br>The mailing list posting you linked was in fact made by a contributor of AVR-LLVM :)</p>
<p style="margin:1.2em 0px!important">The solutions described in the posting:</p>
<ul style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">Convoluted lowering code (with custom lowering for 16-bit operations)</p>
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:1.2em 0px!important;margin:0.5em 0px!important">it lowers loads and stores during combine1 (before legalization), which is way less than ideal. It also uses 32-bit frameindexes<br>(it treats the stack as 32-bit despite global pointers being 64-bit), so I don’t think that provides a>> usable template for a solution here, unfortunately.</p>
</blockquote>
</blockquote>
</li>
<li style="margin:0.5em 0px"><p style="margin:1.2em 0px!important;margin:0.5em 0px!important">Considering pointers to be of different types</p>
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:1.2em 0px!important;margin:0.5em 0px!important">If it would help, one of the changes that we’ve made is to add separate PTRADD, INTTOPTR and PTRTOINT nodes to SelectionDAG, which makes it possible to keep pointer types distinct. We currently have<br>a iFATPTR type, which is not ideal - we’d like to replace this with a set of PTR32 to PTR256 types. I’d be happy to prioritise extracting these patches for upstreaming if that would be useful to others.</p>
</blockquote>
</blockquote>
</li>
</ul>
<p style="margin:1.2em 0px!important">This may not help in our situation, as 16-bit is not a native type but there are still several other operations that can be performed on 16-bit values (not just loads/stores).</p>
<p style="margin:1.2em 0px!important">This is a problem that has been encountered by several different backends, none of which have<br>found satisfactory solutions. The proposed fix would simply give a bit more power to backend<br>maintainers (although admittedly this is necessary for most targets).</p>
<p style="margin:1.2em 0px!important">Back to your previous point</p>
<blockquote style="margin:1.2em 0px;border-left-width:4px;border-left-style:solid;border-left-color:rgb(221,221,221);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style="margin:1.2em 0px!important">I think your proposed solution is a bit of overkill for this problem, because<br>it impacts legalization of all SDNodes, when only a few are actually used<br>for pointer arithmetic.</p>
</blockquote>
<p style="margin:1.2em 0px!important">The case you make is very strong, as the change proposed would break<br>dozens of backends.</p>
<p style="margin:1.2em 0px!important">We could however not cause this problem - a <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">LegalizeAction::Split</code> could be added<br>with the meaning described earlier - split an operation into several smaller operations.<br><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Expand</code> would continue to have its current meaning and operation - it would either split<br>or expand into different operations.</p>
<p style="margin:1.2em 0px!important">The advantage of this is that all backends could specify <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Expand</code> for illegal operations, but<br>targets which need to be specifically split could then use <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Split</code> instead.</p>
<p style="margin:1.2em 0px!important">This would:</p>
<ul style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px">Add the micro-optimization of decreasing code paths for ISel on each node. As the number of<br>nodes can be in the tens or hundreds of thousands for a compilation, this could be fairly beneficial</li>
<li style="margin:0.5em 0px">Current backend maintainers would have the option to change their uses of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Expand</code> to <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Split</code> where<br>appropriate in order to be more explicit</li>
<li style="margin:0.5em 0px">In the future, if <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Split</code> became widespread, it would be much easier to change the meaning of <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-radius:3px;display:inline;background-color:rgb(248,248,248)">Expand</code> if it were to be wanted</li>
<li style="margin:0.5em 0px">Cause no breakage</li>
</ul>
<p style="margin:1.2em 0px!important">What do you think?</p>
<div title="MDH:Jmd0O8KgPHNwYW4gc3R5bGU9ImZvbnQtc2l6ZTogMTIuODAwMDAwMTkwNzM0OXB4OyI+SSB0aGlu
ayB5b3VyIHByb3Bvc2VkIHNvbHV0aW9uIGlzIGEgYml0IG9mIG92ZXJraWxsIGZvciB0aGlzIHBy
b2JsZW0sIGJlY2F1c2U8L3NwYW4+PGJyIHN0eWxlPSJmb250LXNpemU6IDEyLjgwMDAwMDE5MDcz
NDlweDsiPjxzcGFuIHN0eWxlPSJmb250LXNpemU6IDEyLjgwMDAwMDE5MDczNDlweDsiPiZndDtp
dCBpbXBhY3RzIGxlZ2FsaXphdGlvbiBvZiBhbGwgU0ROb2Rlcywgd2hlbiBvbmx5IGEgZmV3IGFy
ZSBhY3R1YWxseSB1c2VkPC9zcGFuPjxiciBzdHlsZT0iZm9udC1zaXplOiAxMi44MDAwMDAxOTA3
MzQ5cHg7Ij48c3BhbiBzdHlsZT0iZm9udC1zaXplOiAxMi44MDAwMDAxOTA3MzQ5cHg7Ij4mZ3Q7
IGZvciBwb2ludGVyIGFyaXRobWV0aWMuPC9zcGFuPjxiciBzdHlsZT0iZm9udC1zaXplOiAxMi44
MDAwMDAxOTA3MzQ5cHg7Ij48ZGl2PjxzcGFuIHN0eWxlPSJmb250LXNpemU6IDEyLjgwMDAwMDE5
MDczNDlweDsiPjxicj48L3NwYW4+PC9kaXY+PGRpdj48c3BhbiBzdHlsZT0iZm9udC1zaXplOiAx
Mi44MDAwMDAxOTA3MzQ5cHg7Ij5JIGFncmVlIHdpdGggeW91LiBJIGRvIGhvd2V2ZXIgdGhpbmsg
dGhhdCBpdCBoYXMgaXRzIGFkdmFudGFnZXMuPC9zcGFuPjwvZGl2PjxkaXY+PHNwYW4gc3R5bGU9
ImZvbnQtc2l6ZTogMTIuODAwMDAwMTkwNzM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B4OyI+V2hhdCBk
byB5b3UgdGhpbms/PC9zcGFuPjwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 13, 2015 at 5:51 AM, Tom Stellard <span dir="ltr"><<a href="mailto:tom@stellard.net" target="_blank">tom@stellard.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Aug 13, 2015 at 05:25:29AM +1200, Dylan McKay via llvm-dev wrote:<br>
> Hello all,<br>
><br>
> I would like to propose a large change to LLVM that I would be happy to<br>
> implement.<br>
><br>
> The instruction selection legalizer knows of three different ways to<br>
> legalize an action (ignoring an already legal action).<br>
><br>
</span>> - Expansion<br>
> - Promotion<br>
> - Custom<br>
<span class="">><br>
> Expanding a node will lead to one of two things - the operation will be<br>
> split into several equivalent smaller operations (i.e. 64-bit mul => two<br>
> 32-bit multiplications), or it will be expanded into a different<br>
> operation(s) (i.e. SDIVREM => SDIV + SREM or a runtime library call).<br>
><br>
> This can be ambiguous - should a 128-bit SDIVREM be expanded into two<br>
> 64-bit SDIVREMs or a 128-bit libcall.<br>
><br>
> It would be useful for LLVM to distinguish between these two operations -<br>
> i.e. instead of LegalizeAction::Expand, we have LegalizeAction::Expand and<br>
> LegalizeAction::Split.<br>
><br>
</span>> -<br>
<span class="">><br>
> Expand should always expand the node into a different pattern (such as<br>
> MULHU expanding to MUL and a copy of the top half).<br>
</span>> -<br>
<span class="">><br>
> Split will always split an operation into several smaller, operations<br>
> (such as 128-bit addition being split into a 64-bit addition and a 64-bit<br>
> addition with carry)<br>
><br>
> Full disclosure: I’m working on a backend on which the pointer type is<br>
> illegal (Atmel AVR : 8-bit microcontroller with 16-bit pointers). The<br>
> problem with the ambiguity with expand today is that LLVM implicitly<br>
> assumes that as a 16-bit register class exists, then 16-bit<br>
> addition/subtraction should exist and there is no point splitting into two<br>
> 8-bit operations.<br>
><br>
<br>
</span>I think your proposed solution is a bit of overkill for this problem, because<br>
it impacts legalization of all SDNodes, when only a few are actually used<br>
for pointer arithmetic.<br>
<br>
Take a look at this thread:<br>
<br>
<a href="http://comments.gmane.org/gmane.comp.compilers.llvm.devel/87321" rel="noreferrer" target="_blank">http://comments.gmane.org/gmane.comp.compilers.llvm.devel/87321</a><br>
<br>
It seems like there are some out of tree patches for handling illegal<br>
pointer types. Maybe you can work with David to get these changes<br>
upstream.<br>
<br>
-Tom<br>
<span class=""><br>
> Currently we work around this by defining 16-bit pseudo instructions for<br>
> every instruction which is not properly supported. This gives us very<br>
> sub-optimal code and introduces many bugs. More detail about the problem<br>
> can be found in the old mailing list archives<br>
</span>> <<a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/087277.html" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/087277.html</a>>.<br>
<span class="">><br>
> I’m not sure if this requires an RFC? It would be a very large breaking<br>
> change. Perhaps a less drastic solution can be found, like leaving Expand<br>
> as it is, but also adding LegalizeAction::Split which must expand only<br>
> using smaller operations.<br>
><br>
> Again, I would be happy to work on this.<br>
><br>
> Cheers,<br>
> Dylan McKay<br>
> <br>
<br>
</span>> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote></div><br></div>