[LLVMdev] global type legalization?
bob.wilson at apple.com
Wed Aug 18 09:22:47 PDT 2010
I'm looking at llvm-generated ARM code that has some unnecessary UXTB (zero extend) instructions, and it seems to me that doing type legalization as an entirely local transformation is not the best approach. I'm thinking in particular about legalizing integer types that need to be promoted to the target register size, i.e., i8 and i16 for ARM promoting to i32.
Currently we sign-extend or zero-extend values of these types at every place where they are defined and used. The definitions are no problem. Loads from memory can specify whether the value should be zero or sign extended, and arithmetic operations are going to produce 32-bit values regardless. Uses (in different basic blocks from the defs) are a different matter. We add explicit zero extend and sign extend operations for every use, despite the fact that the actual register values will have already been extended to 32 bits when they were defined.
It seems like we ought to have a pass to globally promote such types to the target register size.
Has anyone looked at this issue before? Is there already a solution in place that we just need to adopt for ARM? Thoughts on what to do otherwise?
More information about the llvm-dev