[LLVMdev] Troubling promotion of return value to Integer ...

Chris Lattner sabre at nondot.org
Fri May 23 15:19:12 PDT 2008


On May 23, 2008, at 12:53 PM, <Alireza.Moshtaghi at microchip.com> <Alireza.Moshtaghi at microchip.com 
 > wrote:
> Chris,
> Regardless of the optimization problem that we had discussions  
> before, I think we all agreed that promotion of return value should  
> take place in the front-end…

hi Ali, sorry for the delay.

>
> I would like to suggest that when the promotion is done in the Front- 
> end, we do the same and only promote the return value and the  
> function definition does not get promoted:

Right, I agree that this is the right way to go.  We really do need to  
solve the optimization problem first before we can do this though.   
I'll respond with more details to your previous email.

> So for:
>
> char foo() {
>   char c = …
>   return c;
> }
>
> We will have:
>
> define i8 @foo() {
>    ...
>    %tmp = sext i8 ... to i32
>    ret i32 %tmp
> }
>
> And for
>
> int foo() {
>   char c = …
>   return c;
> }
>
> We will have:
>
> define i32 @foo() {
>    ...
>    %tmp = sext i8 ... to i32
>    ret i32 %tmp
> }
>
> Is this acceptable?

Yes, but we need some way for the call to "foo" to say "this i32 is  
known to be sign extended from 8 bits", which allows optimizations to  
occur.  I'll respond more in detail to your other post.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080523/03d99351/attachment.html>


More information about the llvm-dev mailing list