llvm.org GIT mirror llvm / c54dc66
[ConstantFolding] Fix assertion failure on non-power-of-two vector load. Summary: The test case does an (out of bounds) load from a global constant with type <3 x float>. InstSimplify tried to turn this into an integer load of the whole alloc size of the vector, which is 128 bits due to alignment padding, and then bitcast this to <3 x vector> which failed an assertion due to the type size mismatch. The fix is to do an integer load of the normal size of the vector, with no alignment padding. Reviewers: tpr, arsenm, majnemer, dstuttard Reviewed By: arsenm Subscribers: hfinkel, wdng, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63375 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363784 91177308-0d34-0410-b5e6-96231b3b80d8 Jay Foad 3 months ago
2 changed file(s) with 11 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
514514 MapTy = Type::getInt64Ty(C->getContext());
515515 else if (LoadTy->isVectorTy()) {
516516 MapTy = PointerType::getIntNTy(C->getContext(),
517 DL.getTypeAllocSizeInBits(LoadTy));
517 DL.getTypeSizeInBits(LoadTy));
518518 } else
519519 return nullptr;
520520
2727 %load = load <8 x i32>, <8 x i32>* bitcast (i32* getelementptr ([8 x i32], [8 x i32]* @GV, i64 0, i64 -1) to <8 x i32>*)
2828 ret <8 x i32> %load
2929 }
30
31 @constvec = internal constant <3 x float>
32
33 ; This does an out of bounds load from the global constant
34 define <3 x float> @load_vec3() {
35 ; CHECK-LABEL: @load_vec3(
36 ; CHECK-NEXT: ret <3 x float> undef
37 %1 = load <3 x float>, <3 x float>* getelementptr inbounds (<3 x float>, <3 x float>* @constvec, i64 1)
38 ret <3 x float> %1
39 }