llvm.org GIT mirror llvm / 6e8fd90
Change TargetData's algorithm for computing defualt vector type alignment to match what's used in clang and GCC for __alignof, rather than trying to guess what Legalize is going to be doing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102206 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 9 years ago
2 changed file(s) with 14 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
268268 return ABIInfo ? Alignments[i].ABIAlign : Alignments[i].PrefAlign;
269269
270270 // The best match so far depends on what we're looking for.
271 if (AlignType == VECTOR_ALIGN && Alignments[i].AlignType == VECTOR_ALIGN) {
272 // If this is a specification for a smaller vector type, we will fall back
273 // to it. This happens because <128 x double> can be implemented in terms
274 // of 64 <2 x double>.
275 if (Alignments[i].TypeBitWidth < BitWidth) {
276 // Verify that we pick the biggest of the fallbacks.
277 if (BestMatchIdx == -1 ||
278 Alignments[BestMatchIdx].TypeBitWidth < Alignments[i].TypeBitWidth)
279 BestMatchIdx = i;
280 }
281 } else if (AlignType == INTEGER_ALIGN &&
282 Alignments[i].AlignType == INTEGER_ALIGN) {
271 if (AlignType == INTEGER_ALIGN &&
272 Alignments[i].AlignType == INTEGER_ALIGN) {
283273 // The "best match" for integers is the smallest size that is larger than
284274 // the BitWidth requested.
285275 if (Alignments[i].TypeBitWidth > BitWidth && (BestMatchIdx == -1 ||
302292 } else {
303293 assert(AlignType == VECTOR_ALIGN && "Unknown alignment type!");
304294
305 // If we didn't find a vector size that is smaller or equal to this type,
306 // then we will end up scalarizing this to its element type. Just return
307 // the alignment of the element.
308 return getAlignment(cast(Ty)->getElementType(), ABIInfo);
295 // By default, use natural alignment for vector types. This is consistent
296 // with what clang and llvm-gcc do.
297 unsigned Align = getTypeAllocSize(cast(Ty)->getElementType());
298 Align *= cast(Ty)->getNumElements();
299 // If the alignment is not a power of 2, round up to the next power of 2.
300 // This happens for non-power-of-2 length vectors.
301 if (Align & (Align-1))
302 Align = llvm::NextPowerOf2(Align);
303 return Align;
309304 }
310305 }
311306
2323 ; CHECK: paddd
2424 ; CHECK: pextrd
2525 ; CHECK: movq
26 %a = load %i32vec3* %ap
27 %b = load %i32vec3* %bp
26 %a = load %i32vec3* %ap, align 8
27 %b = load %i32vec3* %bp, align 8
2828 %x = add %i32vec3 %a, %b
29 store %i32vec3 %x, %i32vec3* %ret
29 store %i32vec3 %x, %i32vec3* %ret, align 8
3030 ret void
3131 }
3232