if's to switch transformation?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

if's to switch transformation?

Eric van Riet Paap
hello everyone,

I few days ago I had some code (for the PyPy project) that llc -march=c converted to a switch statement and gcc compiled that nicely to a jumptable in the .s file. Now I try to reproduce when directly going from a .ll to a .s file. But I now see a long list of compare and jumps instead of the jumptable. Is there a transformation that does this if->switch(ing) or is that in the part of llc that generates the c file?

cheers
Eric van Riet Paap

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: if's to switch transformation?

Chris Lattner
On Fri, 23 Dec 2005, Eric van Riet Paap wrote:
> I few days ago I had some code (for the PyPy project) that llc -march=c
> converted to a switch statement and gcc compiled that nicely to a jumptable
> in the .s file. Now I try to reproduce when directly going from a .ll to a .s
> file. But I now see a long list of compare and jumps instead of the
> jumptable. Is there a transformation that does this if->switch(ing) or is
> that in the part of llc that generates the c file?

There is one of two things that are happening depending on what you mean.

1. Make sure you're running gccas/gccld to optimize the program.  These
    optimizations are what form the switch stmt.
2. If you're using the native backends, even if #1 is right, you won't get
    switch tables.  The current code generators lower the switches to
    branches.  This is on the near term (within a couple months) TODO list
    to improve, but remains suboptimal for now.

To get the optimization, the best approach is to use gccas/gccld combined
with the C backend.

Sorry!

-Chris

--
http://nondot.org/sabre/
http://llvm.org/

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: if's to switch transformation?

Eric van Riet Paap

On Dec 23, 2005, at 5:18 PM, Chris Lattner wrote:

> On Fri, 23 Dec 2005, Eric van Riet Paap wrote:
>> I few days ago I had some code (for the PyPy project) that llc -
>> march=c converted to a switch statement and gcc compiled that  
>> nicely to a jumptable in the .s file. Now I try to reproduce when  
>> directly going from a .ll to a .s file. But I now see a long list  
>> of compare and jumps instead of the jumptable. Is there a  
>> transformation that does this if->switch(ing) or is that in the  
>> part of llc that generates the c file?
>
> There is one of two things that are happening depending on what you  
> mean.
>
> 1. Make sure you're running gccas/gccld to optimize the program.  
> These
>    optimizations are what form the switch stmt.
> 2. If you're using the native backends, even if #1 is right, you  
> won't get
>    switch tables.  The current code generators lower the switches to
>    branches.  This is on the near term (within a couple months)  
> TODO list
>    to improve, but remains suboptimal for now.
>
> To get the optimization, the best approach is to use gccas/gccld  
> combined with the C backend.

This is what we used for the last couple of months. However, since  
the x86 backend is more actively being improved now I would prefer to  
not use the C backend anymore.

Thank for your swift reply.

cheers
Eric

>
> Sorry!
>
> -Chris
>
> --
> http://nondot.org/sabre/
> http://llvm.org/
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev