diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -519,7 +519,7 @@ MapTy = Type::getInt32Ty(C->getContext()); else if (LoadTy->isDoubleTy()) MapTy = Type::getInt64Ty(C->getContext()); - else if (LoadTy->isVectorTy()) { + else if (LoadTy->isVectorTy() && !LoadTy->getVectorIsScalable()) { MapTy = PointerType::getIntNTy(C->getContext(), DL.getTypeSizeInBits(LoadTy)); } else diff --git a/llvm/test/Analysis/ConstantFolding/vscale.ll b/llvm/test/Analysis/ConstantFolding/vscale.ll --- a/llvm/test/Analysis/ConstantFolding/vscale.ll +++ b/llvm/test/Analysis/ConstantFolding/vscale.ll @@ -185,6 +185,20 @@ %i2 = shufflevector %i, undef, zeroinitializer ret %i2 } + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Memory Access and Addressing Operations +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +define @load() { +; CHECK-LABEL: @load( +; CHECK-NEXT: [[R:%.*]] = load , * getelementptr (, * null, i64 1) +; CHECK-NEXT: ret [[R]] +; + %r = load , * getelementptr (, * null, i64 1) + ret %r +} + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Conversion Operations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;