<div dir="ltr">Hi Milind,<div><br></div><div>My suggestion just for your concern that if you eliminate the default block, a block associated with a case value will become the default block of the swhich instruction, since a switch instruction always requires a default block.</div>
<div>But when a block associated with a case value become the default block, the associated case value is lost and may confuse the later optimizations such as<span style="font-family:arial,sans-serif;font-size:13px"> </span><span style="font-family:arial,sans-serif;font-size:13px">constant propagation.</span></div>
<div><br></div><div>To prevent such information lost when you eliminate the default block and make a block associated with a case value will become the default block, you can attach a metadata[1] to the switch instruction to provide the case value of the default block.</div>
<div><br></div><div>In order to take the advantage of the attached metadata for the default case of the switch instruction you also need to modify the later optimization accordingly.</div><div><br></div><div>Thanks</div><div>
Hongbin</div><div><br></div><div>[1]<a href="http://blog.llvm.org/2010/04/extensible-metadata-in-llvm-ir.html">http://blog.llvm.org/2010/04/extensible-metadata-in-llvm-ir.html</a><br><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Jul 18, 2013 at 2:30 PM, Milind Chabbi <span dir="ltr"><<a href="mailto:Milind.Chabbi@rice.edu" target="_blank">Milind.Chabbi@rice.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hongbin<br>
<br>
Can you elaborate more on your suggestion? I am not sure I fully<br>
understand what you suggested.<br>
<span class=""><font color="#888888"><br>
-Milind<br>
</font></span><div class=""><div class="h5"><br>
On Wed, Jul 17, 2013 at 11:11 PM, Hongbin Zheng <<a href="mailto:etherzhhb@gmail.com">etherzhhb@gmail.com</a>> wrote:<br>
> Hi Milind,<br>
><br>
> Maybe you could annotate the default case value as metadata to the swith<br>
> instruction.<br>
><br>
> Thanks<br>
> Hongbin<br>
><br>
><br>
> On Thu, Jul 18, 2013 at 1:09 PM, Milind Chabbi <<a href="mailto:Milind.Chabbi@rice.edu">Milind.Chabbi@rice.edu</a>><br>
> wrote:<br>
>><br>
>> Hi Mark,<br>
>><br>
>> This will workaround the problem of "default" branch restriction on<br>
>> the switch instruction. The trouble with this technique is that it<br>
>> will trump later optimization phases such as constant propagation.<br>
>> When a block was part of a case, because of the knowledge of the case<br>
>> value, the block was a candidate for better optimization. However,<br>
>> when we move the body of the case into the default, the knowledge of<br>
>> the case value is lost and the body is less optimizable.<br>
>><br>
>> -Milind<br>
>><br>
>><br>
>> On Wed, Jul 17, 2013 at 9:29 PM, Mark Lacey <<a href="mailto:mark.lacey@apple.com">mark.lacey@apple.com</a>> wrote:<br>
>> > On Jul 17, 2013, at 9:01 PM, Milind Chabbi <<a href="mailto:Milind.Chabbi@rice.edu">Milind.Chabbi@rice.edu</a>><br>
>> > wrote:<br>
>> >> I am performing a transformation that requires changing the targets of<br>
>> >> a basic block ending with a switch instruction.<br>
>> >> In particular, I need to delete the edge that goes to the "default"<br>
>> >> basic block.<br>
>> >> But, LLVM switch instruction always wants a default target basic block<br>
>> >> for a switch instruction.<br>
>> >> It is not clear how to accomplish this, since I don't have a<br>
>> >> replacement default target block.<br>
>> >> I could potentially fake that edge to be one of the other case label<br>
>> >> targets, but that is an ugly hack and I don't want to do that.<br>
>> >> I would appreciate if you can suggest better alternatives.<br>
>> ><br>
>> > Hi Milind,<br>
>> ><br>
>> > If you make the "default" branch to a block that has an UnreachableInst<br>
>> > as a terminator, the SimplifyCFG pass will remove one of the switch cases<br>
>> > and replace the block that the default branches to with the block that this<br>
>> > removed case branches to. This sounds a lot like the "ugly hack" that you<br>
>> > would like to avoid. Would it be a reasonable solution for what you are<br>
>> > trying to accomplish?<br>
>> ><br>
>> > Mark<br>
>> ><br>
>> ><br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
</div></div></blockquote></div><br></div></div></div>