[LLVMdev] Floats as Doubles in Vectors

Hal Finkel hfinkel at anl.gov
Sun Jan 27 14:07:18 PST 2013

Nadav, et al.,

On the BG/Q, the vectors hold 4 double-precision values. For vectorizing single-precision code, there are single-precision-rounded instructions, and special load/store instructions, which allow the double-precision numbers to be treated as single-precision numbers. The problem is that the current vectorization code (in the BBVectorizer and, as far as I can tell, also in the LoopVectorizer) is going to assume that the vectors can hold 256/32 == 8 single-precision values even though the real maximum is 4 values. How should we handle this? A couple of thoughts:

1. Do nothing and let the type legalization cost take care of penalizing the formation of <8 x float> vectors. This may work, but will cause an unnecessary compile-time increase.

2. Add some kind of API to TTI that allows the default logic (# == vector-size/type-size) to be overridden. This could be something specific to the problem at hand, such as: bool areFloatsStoredAsDoublesInVectors(), or something more general. Maybe something like: unsigned getSizeAsVectorElement(Type *T) which would return the number of bytes that the specified type actually takes up when used as a vector element.

I'm certainly open to suggestions. I don't know if this situation applies to other targets as well.

Thanks again,

Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory

More information about the llvm-dev mailing list