<p dir="ltr">The loop that checks 'ValuePair.second == DefaultValue' seems to be constant across the loop where reuseTableCompare is called. Can you hoist that above the loop?</p>
<p dir="ltr">Also a typo 'agains' should be 'against'.</p>
<p dir="ltr">Joey</p>
<div class="gmail_quote">On 18 Nov 2014 15:55, "Erik Eckstein" <<a href="mailto:eeckstein@apple.com">eeckstein@apple.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Hans,<br>
<br>
I have another patch for the switch table lookup generation. It tries to reuse the generated compare instruction, if there is a comparison agains the default value after the switch.<br>
<br>
Example:<br>
<br>
switch (x) {<br>
case 0: r = 10; break;<br>
case 1: r = 11; break;<br>
...<br>
default: r = 0; break; // 0 does not appear in any case value.<br>
}<br>
if (r == 0) {<br>
do_something;<br>
}<br>
<br>
transforms to:<br>
<br>
if (x < table_size) {<br>
r = table[x];<br>
} else {<br>
r = 0;<br>
do_something;<br>
}<br>
<br>
Now I must admit, that this pattern is quite a corner case (only a single occurrence in the test-suite). My trigger for this optimization is that in our project we are generating such IR patterns.<br>
<br>
Please let me know your comments.<br>
<br>
Thanks,<br>
Erik<br>
<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div>