Promotion of integral values

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.

Rob

Robert L. Bocchino Jr.
Ph.D. Student, Computer Science
University of Illinois, Urbana-Champaign

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 effect.

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.

-Chris

Were there ever any plans to make a staged emulator that only JIT's hot
functions (interpreting the lesser used ones)? Emulators such as this tend
to perform better when there are a lot of infrequently used functions.

I'm not aware of any work to implement this sort of thing, but it shouldn't be too hard. We're currently lacking a decent interpreter, so that would be the first place to start.

-Chris

Were there ever any plans to make a staged emulator that only JIT's hot
functions (interpreting the lesser used ones)? Emulators such as this

tend

to perform better when there are a lot of infrequently used functions.

I'm not aware of any work to implement this sort of thing, but it
shouldn't be too hard. We're currently lacking a decent interpreter, so
that would be the first place to start.

-Chris

I might be able to work on that in spare time, we'll see. Do you think it's a worthwhile thing to work on?

If you're interested in working on this, you should probably talk to Chris Morgan, who was recently asking about the interpreter:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2005-September/004799.html

-Chris

From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu] On
Behalf Of Chris Lattner
Sent: Thursday, September 15, 2005 1:18 PM
To: LLVM Developers Mailing List
Subject: Re: [LLVMdev] Staged LLVM emulator

Were there ever any plans to make a staged emulator that only JIT's hot
functions (interpreting the lesser used ones)? Emulators such as this

tend

to perform better when there are a lot of infrequently used functions.

I'm not aware of any work to implement this sort of thing, but it
shouldn't be too hard. We're currently lacking a decent interpreter, so
that would be the first place to start.

-Chris

-Chris