[LLVMdev] Promotion of integral values

Chris Lattner sabre at nondot.org
Wed Sep 14 19:44:19 PDT 2005

On Wed, 14 Sep 2005, Robert L. Bocchino Jr. wrote:
> There's some optimization that turns expressions like this:
>  short a = ...
>  short b =
>  int a' = cast short a to int
>  int b' = cast short b to int
>  int c = a' + b'
> into this:
>  short a = ...
>  short b = ...
>  uint a' = cast short a to uint
>  uint b' = cast short b to uint
>  uint c = a' + b'
>  int c = cast uint c to int
> Does anyone know which optimization is doing this?  I'd like to be able to 
> turn it off.

Hard to say without more information.  This is a semantically valid xform, 
so it's not "wrong" that it's doing it.  To find out what is doing it, 
pass -debug-pass=Arguments to gccas or gccld (whichever is doing it). 
This will give you a list of passes you can give to opt to get the same 

You can use this list of passes to do a binary search for the pass that is 
doing the xform.  If I had to guess, I'd say instcombine, levelraise or indvars.



More information about the llvm-dev mailing list