<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>No active work on my side, but I have given the topic of threaded
interpreters (which is what I think you're wanting to produce) a
good amount of thought. <br>
</p>
<p>I'm really not sure that switch is the right canonical form. The
main reason being that having a loop over a large switch is very
likely to encourage code motion which is generally profitable, but
harmful in this particular context.</p>
<p>I had been thinking down the lines of representing the intepreter
as a family of mutually recursive functions with a calling
convention optimized for this case and using a musttail call
through a lookup table for the dispatch. </p>
<p>I've played with the notion of extending clang with a custom
attribute for guaranteed tail calls. I think this is pretty much
the only extension needed to be able to natively write out a
threaded interpreter as a set of mutually recursive functions.</p>
<p>This is all thought experiment from my side; I haven't had time
to sit down and actually prototype any of this.</p>
<p>Philip<br>
</p>
<div class="moz-cite-prefix">On 9/23/20 7:33 AM, Phipps, Alan via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:0bae5255868142479a323f52fd260868@ti.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">It is my understanding that the
implementation for jump-threading in LLVM is not presently
able to effectively optimize code containing a state-machine
implemented using a loop + switch. This is the case, for
example, with the Coremark benchmark function
core_state_transition(). Bug 42313 was filed to address this
in 2019:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a
href="https://bugs.llvm.org/show_bug.cgi?id=42313"
moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=42313</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It appears that GCC improved support for
jump threading in 2015 along the same lines:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><a
href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54742"
moz-do-not-send="true">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54742</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is anyone aware of any plan to do improve
LLVM jump-threading along the same lines for LLVM?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Alan Phipps<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
</body>
</html>