[LLVMdev] type legalizer promoting BUILD_VECTORs

Eli Friedman eli.friedman at gmail.com
Mon Feb 2 13:51:32 PST 2009


On Mon, Feb 2, 2009 at 11:31 AM, Bob Wilson <bob.wilson at apple.com> wrote:
> LLVM's type legalizer is changing the types of BUILD_VECTORs in a way
> that seems wrong to me, but I'm not sure if this is a bug or if some
> targets may be relying on it.
>
> On a 32-bit target, the default action for legalizing i8 and i16 types
> is to promote them.

This isn't true on x86.

> If you then have a BUILD_VECTOR to construct a
> legal vector type composed of i8 or i16 values, the type legalizer
> will look at the BUILD_VECTOR operands and decide that it needs to
> promote them to i32 types.  You end up with a BUILD_VECTOR that
> constructs a vector of i32 values that are then bitcast to the
> original vector type.

I'm pretty sure the target-independent legalizer does no such thing.
Can you point to the code you're talking about?

That said, I do recall the x86 backend does a similar
platform-specific transformation with constants... do you care about
x86 in particular?

> This works fine for SSE, where it appears that BUILD_VECTORs are
> intentionally canonicalized to use i32 elements for the benefit of
> CSE.  I'm looking at implementing something where I think I'd like to
> keep the original vector types.  Is this behavior in the type
> legalizer something that should be changed?

I'm not sure what behavior you're talking about...

-Eli



More information about the llvm-dev mailing list