<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body>
<p>Just wanted to chime in here and say that having a good robust
specialization pass would be very valuable. As you highlight
though, the cost modeling is the tricky bit. Getting a cost model
worked through that works well in practice - in particular, when
combined with the existing inliner cost model - is a major task.
I suspect, without much evidence, that you'll end up having the
balance the cost model for specialization against the cost model
for inlining - and thus probably have to adjust both. That is, to
say the least, challenging. If you're willing to take on that
work, I'll simply say thank you and good luck. :)<br>
</p>
<p><br>
</p>
<p>One thing you could consider is exploring the notion of "zero
cost" specialization. The analogy I'd use is the cost model we
use for the new loop unswitch. The old loop unswitch was pretty
aggressive, whereas the new one requires the transformation to
recover (almost all of) the cost of the transformed loop overhead.</p>
<p><br>
</p>
<p>I've spent some time in the past thinking about what a zero cost
specializer might look like. I think there's some very
interesting possibilities looking at it through the lens of
function splitting combined with musttail dispatch. Let me give a
small example using one of your motivating routines. Starting
with:<br>
</p>
<div><br>
</div>
<div>long compute(long x, long (*binop)(long) ) {</div>
<div> return binop(x);</div>
<div>}</div>
<div><br>
</div>
<div>int foo(int x, int y) {</div>
<div> if (y)</div>
<div> return compute(x, plus);</div>
<div> else</div>
<div> return compute(x, minus);</div>
<p>
}</p>
<p><br>
</p>
<p>This can become (at zero cost):</p>
<div>
<div>long compute(long x, long (*binop)(long) ) {</div>
<div> return binop(x);</div>
<div>}</div>
<div>long computeA(long x) { return compute(x, plus); }<br>
</div>
<div>long computeB(long x) { return compute(x, minus); }<br>
</div>
int foo(int x, int y) {</div>
<div> if (y)</div>
<div> return musttail computeA(x);</div>
<div> else</div>
<div> return musttail computeB(x);</div>
<p>}</p>
<p><br>
</p>
<p>If you think about what that lowers to, foo ends up simply being
the branch dispatch to the other routines. There's some space
overhead due to function alignment, and lost fallthrough
opportunity, but that's it. <br>
</p>
<p><br>
</p>
<p>Why bother? Well, on this example, it's hard to justify because
the inliner would happily blow through the whole thing, but on
larger examples we've made the dispatch in foo dramatically easier
for the caller to inline. That's particular interesting when a
subset of callers have analyzable or predictable (in the branch
predictor sense) values for y. <br>
</p>
<p><br>
</p>
<p>Anyways, just a random through dump. If any of this is useful,
feel free to use, if not, feel free to ignore. :)<br>
</p>
<p><br>
</p>
<p>Philip<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 3/23/21 12:44 PM, Sjoerd Meijer via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:DB6PR0801MB19904ECD095140D915F86A09FC649@DB6PR0801MB1990.eurprd08.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
I am interested in adding a function specialisation(*) pass to
LLVM. This frequently</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
comes up as a reason for performance differences of generated
code between</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
GCC and LLVM. In GCC this <span style="color: rgb(0, 0, 0);
font-family: Calibri, Arial, Helvetica, sans-serif; font-size:
12pt; background: var(--white);">is implemented in [1] and
gets enabled at</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">optimisation level -03 and up. There have been
two previous attempts in adding</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">this to LLVM: a while back this was attempted
in [2] and very recently in [3].</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
Both previous attempts were parked at approximately the same
point: the</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
transformation was implemented but the cost-model to control
compile-times</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
and code-size was lacking. This is crucial as the goal would be
to have</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
function specialisation <span style="color: rgb(0, 0, 0);
font-family: Calibri, Arial, Helvetica, sans-serif; font-size:
12pt; background: var(--white);">enabled by default (at some
opt level) and function </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">cloning has of course great potential to </span><span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">increase code-size and the</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">interprocedural analysis isn't very cheap. </span><span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">Thus, I </span><span style="color: rgb(0, 0,
0); font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; background: var(--white);">agree with
previous comments</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">on both tickets that we probably need to </span><span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">have a solid story for this before it makes</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">sense to add this to the LLVM </span><span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">code-base.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
Given that GCC has this enabled by default we are in an <span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">excellent position to</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">evaluate the compile-time/code-size overhead of
function specialiation. For two</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">cases I have tried </span><span style="color:
rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica,
sans-serif; font-size: 12pt; background: var(--white);">investigating
this </span><span style="color: rgb(0, 0, 0); font-family:
Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;
background: var(--white);">overhead (and didn't </span><span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">evaluate performance of</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">the generated </span><span style="color: rgb(0,
0, 0); font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; background: var(--white);">code). First, I
took </span><span style="color: rgb(0, 0, 0); font-size: 12pt;
caret-color: rgb(29, 28, 29); font-family: calibri, arial,
helvetica, sans-serif; background: var(--white);">SQLite's
amalgamation </span><span style="color: rgb(0, 0, 0);
font-size: 12pt; caret-color: rgb(29, 28, 29); font-family:
calibri, arial, helvetica, sans-serif; background:
var(--white);">version, i.e. 1 source file</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">that is </span><span
style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">"220,000 lines long
and </span><span class="p-rich_text_section" style="color:
rgb(0, 0, 0); font-size: 12pt; counter-reset: list-0 0 list-1
0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8
0 list-9 0; caret-color: rgb(29, 28, 29); font-family:
calibri, arial, helvetica, sans-serif;">over 7.5 megabytes in </span><span
class="p-rich_text_section" style="color: rgb(0, 0, 0);
font-size: 12pt; counter-reset: list-0 0 list-1 0 list-2 0
list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9
0; caret-color: rgb(29, 28, 29); font-family: calibri, arial,
helvetica, sans-serif;">size" [4</span><span
class="p-rich_text_section" style="color: rgb(0, 0, 0);
font-size: 12pt; counter-reset: list-0 0 list-1 0 list-2 0
list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9
0; caret-color: rgb(29, 28, 29); font-family: calibri, arial,
helvetica, sans-serif;">] as that seemed like a</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span class="p-rich_text_section" style="color: rgb(0, 0, 0);
font-size: 12pt; counter-reset: list-0 0 list-1 0 list-2 0
list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9
0; caret-color: rgb(29, 28, 29); font-family: calibri, arial,
helvetica, sans-serif;">good stress test for an IPA </span><span
style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white);">transformation pass to me.
Comparing GCC 10.2.0</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white);">with
</span><span style="caret-color: rgb(29, 28, 29); color: rgb(0,
0, 0); font-family: calibri, arial, helvetica, sans-serif;
font-size: 12pt; background: var(--white); background-color:
rgb(255, 255, 255);">-O3 and </span><span style="caret-color:
rgb(29, 28, 29); color: rgb(0, 0, 0); font-family: calibri,
arial, helvetica, sans-serif; font-size: 12pt; background:
var(--white); background-color: rgb(255, 255, 255);">"-O3 </span><span
style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background-color: rgb(255, 255, 255);">-fdisable-ipa-cp</span><span
style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white); background-color: rgb(255,
255, 255);">" to</span><span style="caret-color: rgb(29, 28,
29); color: rgb(0, 0, 0); font-family: calibri, arial,
helvetica, sans-serif; font-size: 12pt; background:
var(--white);"> toggle this on and off, respectively, </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white);">showed a 0.3% - 1.5% </span><span
style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white);">compile-time difference on
different systems and a </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white);">1.3% object file increase. </span><span
class="p-rich_text_section" style="color: rgb(0, 0, 0);
font-size: 12pt; counter-reset: list-0 0 list-1 0 list-2 0
list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9
0; caret-color: rgb(29, 28, 29); font-family: calibri, arial,
helvetica, sans-serif;">Second, I timed compilation of </span><span
style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">LLVM, representing a</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">very different
codebase. For LLMV </span><span style="color: rgb(0, 0, 0);
font-size: 12pt; caret-color: rgb(29, 28, 29); font-family:
calibri, arial, helvetica, sans-serif; background:
var(--white);">compile time differences were all within noise</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">levels with only a </span><span
style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">tiny </span><span
style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">code-size increase. I
haven't looked into details here, but I</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">guess that it is not </span><span
style="color: rgb(0, 0, 0); font-size: 12pt; caret-color:
rgb(29, 28, 29); font-family: calibri, arial, helvetica,
sans-serif; background: var(--white);">doing </span><span
style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white);">much, which could be the
benefit of a well-tuned </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="caret-color: rgb(29, 28, 29); color: rgb(0, 0, 0);
font-family: calibri, arial, helvetica, sans-serif; font-size:
12pt; background: var(--white);">cost-model, so is a good
result.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
Another reason why I am widening the audience with this email is
that</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
alternative approaches were floated. In [2] it was remarked
that <span style="color: rgb(0, 0, 0); font-size: 12pt;
font-family: calibri, arial, helvetica, sans-serif;">"</span><span
style="color: rgb(0, 0, 0); font-size: 12pt; font-family:
calibri, arial, helvetica, sans-serif;">we could </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family:
calibri, arial, helvetica, sans-serif;">propagate constant
sets indicating the functions indirect call sites could
possibly</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family:
calibri, arial, helvetica, sans-serif;">target. Although we
would probably want to limit the size of the sets to something</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family:
calibri, arial, helvetica, sans-serif;">small, </span><span
style="color: rgb(0, 0, 0); font-family: calibri, arial,
helvetica, sans-serif; font-size: 12pt; background:
var(--white);">the pass could attach the sets via metadata to
the calls so that this information</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: calibri, arial,
helvetica, sans-serif; font-size: 12pt; background:
var(--white);">could be </span><span style="color: rgb(0, 0,
0); font-family: calibri, arial, helvetica, sans-serif;
font-size: 12pt; background: var(--white);">consumed by later
passes. Such metadata could be used for indirect call</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: calibri, arial,
helvetica, sans-serif; font-size: 12pt; background:
var(--white);">promotion, </span><span style="color: rgb(0, 0,
0); font-size: 12pt; font-family: calibri, arial, helvetica,
sans-serif;">intersecting the function attributes of the
possible targets</span><span style="color: rgb(0, 0, 0);
font-size: 12pt; font-family: calibri, arial, helvetica,
sans-serif;">". </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family:
calibri, arial, helvetica, sans-serif;"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family:
calibri, arial, helvetica, sans-serif;">But I am reluctant to
go for this let's say more experimental approach as the GCC</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-size: 12pt; font-family:
calibri, arial, helvetica, sans-serif;">numbers </span><span
style="color: rgb(0, 0, 0); font-family: calibri, arial,
helvetica, sans-serif; font-size: 12pt; background:
var(--white);">are very encouraging. I.e., both compile-time
and code-size seem very</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: calibri, arial,
helvetica, sans-serif; font-size: 12pt; background:
var(--white);">reasonable and I don't have seen yet any
reasons to abandon the approaches in</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: calibri, arial,
helvetica, sans-serif; font-size: 12pt; background:
var(--white);">[2] and [3] which </span><span style="color:
rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica,
sans-serif; font-size: 12pt; background: var(--white);">are
very similar. So, the approach I would like to take is
complement</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">[3] with an analysis </span><span style="color:
rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica,
sans-serif; font-size: 12pt; background: var(--white);">of the
added compile-time/code-size increase, and then propose a</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">cost-model </span><span style="color: rgb(0, 0,
0); font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; background: var(--white);">which then
hopefully gives results in the range of GCC; I think that is
what</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">we </span><span style="color: rgb(0, 0, 0);
font-family: Calibri, Arial, Helvetica, sans-serif; font-size:
12pt; background: var(--white);">should be aiming </span><span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">at. But I am interested to hear if there are
more/other opinions on</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; font-size: 12pt; background:
var(--white);">this.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
(*) Motivating examples for function specialisation in previous
works were e.g.:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
long plus(long x) {
<div> return x + 1;</div>
<div>}</div>
<div>long minus(long x) {</div>
<div> return x - 1;</div>
<div>}</div>
<div>long compute(long x, long (*binop)(long) ) {</div>
<div> return binop(x);</div>
<div>}</div>
<div>int foo(int x, int y) {</div>
<div> if (y)</div>
<div> return compute(x, plus);</div>
<div> else</div>
<div> return compute(x, minus);</div>
}<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
If we specialise compute which gets inlined in foo, we end up
with just a return x + 1</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
and return x -1 in foo. Other motivating examples pass constants
to functions, which</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
can then get propagated after function specialisation. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<span style="margin:0px;font-size:12pt;caret-color:rgb(0, 0,
0);background-color:rgb(255, 255, 255)">[1] <a
href="https://github.com/gcc-mirror/gcc/blob/master/gcc/ipa-cp.c"
style="margin:0px" moz-do-not-send="true">https://github.com/gcc-mirror/gcc/blob/master/gcc/ipa-cp.c</a></span>
<div style="margin:0px;font-size:12pt;caret-color:rgb(0, 0,
0);background-color:rgb(255, 255, 255)">
[2] <a href="https://reviews.llvm.org/D36432"
style="margin:0px" moz-do-not-send="true">https://reviews.llvm.org/D36432</a></div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview
_EReadonly_1" style="margin:0px;font-family:"Segoe
UI", "Segoe UI Web (West European)",
"Segoe UI", -apple-system, BlinkMacSystemFont,
Roboto, "Helvetica Neue",
sans-serif;font-size:14px;caret-color:rgb(0, 0,
0);background-color:rgb(255, 255, 255)">
</div>
<div style="margin:0px;font-size:12pt;caret-color:rgb(0, 0,
0);background-color:rgb(255, 255, 255)">
[3] <a href="https://reviews.llvm.org/D93838"
style="margin:0px" moz-do-not-send="true">https://reviews.llvm.org/D93838</a></div>
<div style="margin:0px;font-size:12pt;caret-color:rgb(0, 0,
0);background-color:rgb(255, 255, 255)">
[4] <a href="https://www.sqlite.org/amalgamation.html"
style="margin:0px" moz-do-not-send="true">https://www.sqlite.org/amalgamation.html</a></div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview_2
_EReadonly_1" style="margin:0px;font-family:"Segoe
UI", "Segoe UI Web (West European)",
"Segoe UI", -apple-system, BlinkMacSystemFont,
Roboto, "Helvetica Neue",
sans-serif;font-size:14px;caret-color:rgb(0, 0,
0);background-color:rgb(255, 255, 255)">
</div>
<br>
</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>