mirror of
https://github.com/gomson/TimothyLottes.github.io.git
synced 2026-11-14 10:10:07 -08:00
Add files via upload
This commit is contained in:
1 parent
85320961f1
commit
2e415e7239
3 files changed
+23
-1
No files matched your search
@@ -0,0 +1,10 @@
|
||||
<html><head><link rel="stylesheet" href="style.css"></head><body><div class="page">
|
||||
<h1>20101004 - MSVC Optimizing Static Constant Function Tables?</h1>
|
||||
<br>
|
||||
|
||||
|
||||
Nope. Would be nice if the MSVC compiler could optimize FunctionJump() like FunctionIf() below,<br /><br /><!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #8f5902; font-style: italic">#include <stdio.h></span><br /><br /><span style="color: #204a87; font-weight: bold">typedef</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000; font-weight: bold">(</span><span style="color: #ce5c00; font-weight: bold">*</span><span style="color: #000000">Function</span><span style="color: #000000; font-weight: bold">)(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span><span style="color: #000000; font-weight: bold">);</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionA</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">printf</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #4e9a06">"a=%d\n"</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">);</span> <span style="color: #000000; font-weight: bold">}</span><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionB</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">printf</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #4e9a06">"b=%d\n"</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">);</span> <span style="color: #000000; font-weight: bold">}</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">const</span> <span style="color: #000000">Function</span> <span style="color: #000000">function</span><span style="color: #000000; font-weight: bold">[</span><span style="color: #0000cf; font-weight: bold">2</span><span style="color: #000000; font-weight: bold">]</span> <span style="color: #ce5c00; font-weight: bold">=</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">FunctionA</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #000000">FunctionB</span> <span style="color: #000000; font-weight: bold">};</span><br /> <br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionJump</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #000000">function</span><span style="color: #000000; font-weight: bold">[</span><span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">](</span><span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">);</span> <span style="color: #000000; font-weight: bold">}</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">FunctionIf</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">const</span> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">input</span><span style="color: #000000; font-weight: bold">)</sLine truncated
|
||||
|
||||
</div></body></html>
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<html><head><link rel="stylesheet" href="style.css"></head><body><div class="page">
|
||||
<h1>20101005 - MSVC Optimizing Static Constant Data Copy?</h1>
|
||||
<br>
|
||||
|
||||
Yes. All extra copies factored out.<br /><br /><!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #8f5902; font-style: italic">#include <stdio.h></span><br /><br /><span style="color: #204a87; font-weight: bold">typedef</span> <span style="color: #204a87; font-weight: bold">struct</span> <span style="color: #000000; font-weight: bold">{</span> <br /> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">a</span><span style="color: #000000; font-weight: bold">;</span><br /> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">b</span><span style="color: #000000; font-weight: bold">;</span><br /> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">c</span><span style="color: #000000; font-weight: bold">;</span><br /> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">d</span><span style="color: #000000; font-weight: bold">;</span><br /><span style="color: #000000; font-weight: bold">}</span> <span style="color: #000000">DataA</span><span style="color: #000000; font-weight: bold">;</span><br /><br /><span style="color: #204a87; font-weight: bold">typedef</span> <span style="color: #204a87; font-weight: bold">struct</span> <span style="color: #000000; font-weight: bold">{</span><br /> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">a</span><span style="color: #000000; font-weight: bold">;</span><br /> <span style="color: #204a87; font-weight: bold">int</span> <span style="color: #000000">d</span><span style="color: #000000; font-weight: bold">;</span><br /><span style="color: #000000; font-weight: bold">}</span> <span style="color: #000000">DataB</span><span style="color: #000000; font-weight: bold">;</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">const</span> <span style="color: #000000">DataA</span> <span style="color: #000000">dataA</span> <span style="color: #ce5c00; font-weight: bold">=</span> <span style="color: #000000; font-weight: bold">{</span> <span style="color: #0000cf; font-weight: bold">0</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #0000cf; font-weight: bold">1</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #0000cf; font-weight: bold">2</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #0000cf; font-weight: bold">3</span> <span style="color: #000000; font-weight: bold">};</span><br /><br /><span style="color: #204a87; font-weight: bold">static</span> <span style="color: #204a87; font-weight: bold">__forceinline</span> <span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">DataCopy</span><span style="color: #000000; font-weight: bold">(</span><br /><span style="color: #000000">DataB</span><span style="color: #ce5c00; font-weight: bold">*</span> <span style="color: #000000">__restrict</span> <span style="color: #204a87; font-weight: bold">const</span> <span style="color: #000000">dataB</span><span style="color: #000000; font-weight: bold">,</span> <span style="color: #204a87; font-weight: bold">const</span> <span style="color: #000000">DataA</span><span style="color: #ce5c00; font-weight: bold">*</span> <span style="color: #000000">__restrict</span> <span style="color: #204a87; font-weight: bold">const</span> <span style="color: #000000">dataA</span><span style="color: #000000; font-weight: bold">)</span> <span style="color: #000000; font-weight: bold">{</span><br /> <span style="color: #000000">dataB</span><span style="color: #ce5c00; font-weight: bold">-></span><span style="color: #000000">a</span> <span style="color: #ce5c00; font-weight: bold">=</span> <span style="color: #000000">dataA</span><span style="color: #ce5c00; font-weight: bold">-></span><span style="color: #000000">a</span><span style="color: #000000; font-weight: bold">;</span><br /> <span style="color: #000000">dataB</span><span style="color: #ce5c00; font-weight: bold">-></span><span style="color: #000000">d</span> <span style="color: #ce5c00; font-weight: bold">=</span> <span style="color: #000000">dataA</span><span style="color: #ce5c00; font-weight: bold">-></span><span style="color: #000000">d</span><span style="color: #000000; font-weight: bold">;</span> <span style="color: #000000; font-weight: bold">}</span><br /><br /><span style="color: #204a87; font-weight: bold">void</span> <span style="color: #000000">main</span><span style="color: #000000; font-weight: bold">(</span><span style="color: #204a87; font-weight: bold">void</span><span style="color: #000000; font-weight: bold">)<Line truncated
|
||||
|
||||
</div></body></html>
|
||||
|
||||
|
||||
+4
-1
@@ -40,7 +40,7 @@ and attempting to restore what I can from prior lost images.
|
||||
<br>
|
||||
<br>
|
||||
<ul>
|
||||
<li>250 pages left to sort through on blogger
|
||||
<li>245 pages left to sort through on blogger
|
||||
<li>65 pages left to sort through on atom
|
||||
<li>60 docs left to sort through on drive
|
||||
</ul>
|
||||
@@ -248,6 +248,9 @@ and attempting to restore what I can from prior lost images.
|
||||
<a href="20110907.html">20110907 - Parallel Programming With Clones</a><br>
|
||||
<br>
|
||||
<b>2010</b><br>
|
||||
<a href="20101005.html">20101005 - MSVC Optimizing Static Constant Data Copy?</a><br>
|
||||
<a href="20101004.html">20101004 - MSVC Optimizing Static Constant Function Tables?</a><br>
|
||||
<br>
|
||||
<a href="20100108.html">20100108 - AntiPlanet2</a><br>
|
||||
<a href="20100105.html">20100105 - Game Engine Architecture</a><br>
|
||||
<a href="20100104.html">20100104 - OnLive Notes</a><br>
|
||||
|
||||
Reference in new issue
Block a user