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

Alireza.Moshtaghi at microchip.com Alireza.Moshtaghi at microchip.com
Fri May 16 16:07:38 PDT 2008


To me, this "optimization" problem doesn't seem to be a consequence of
doing the promotion differently than what is currently being done in
llvm. 

Anyways, I don't agree that the information is completely lost.
Shouldn't an llvm pass be able to figure out if the truncated value is
coming from a function call, and since it is aware of calling
convention, it should be able to deduce that tmp2 can really take its
value from function call?

 

So the pass will modify 

 

define i32 @bar() {

  ; call

  %tmp = call i32 @foo()

  %x = trunc i32 %tmp to i8

 

  ; return

  %tmp2 = sext i8 to i32

  ret i32 %tmp2

}

 

To

 

define i32 @bar() {

  ; call

  %tmp = call i32 @foo()

  %tmp2 = %tmp

  %x = trunc i32 %tmp to i8

 

  ; return

  ret i32 %tmp2

}

 

Meanwhile, the FrontEnd is consistent with the calling convention and
produce the correct IR with necessary promotions.

 

Ali

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080516/0c14573c/attachment.html>


More information about the llvm-dev mailing list