diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2630,12 +2630,13 @@ Type *SelectorTy = Type::getInt1Ty(Context); - // The selector might be an i1 or an + // The selector might be an i1, an , or a // Get the type from the ValueList before getting a forward ref. if (VectorType *VTy = dyn_cast(CurTy)) if (Value *V = ValueList[Record[0]]) if (SelectorTy != V->getType()) - SelectorTy = VectorType::get(SelectorTy, VTy->getNumElements()); + SelectorTy = VectorType::get(SelectorTy, + VTy->getElementCount()); V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0], SelectorTy), @@ -2693,7 +2694,7 @@ Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy); Type *ShufTy = VectorType::get(Type::getInt32Ty(Context), - OpTy->getNumElements()); + OpTy->getElementCount()); Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); break; @@ -2707,7 +2708,7 @@ Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); Type *ShufTy = VectorType::get(Type::getInt32Ty(Context), - RTy->getNumElements()); + RTy->getElementCount()); Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); break; @@ -4168,9 +4169,10 @@ return error("Invalid record"); if (!Vec1->getType()->isVectorTy() || !Vec2->getType()->isVectorTy()) return error("Invalid type for value"); + I = new ShuffleVectorInst(Vec1, Vec2, Mask); FullTy = VectorType::get(FullTy->getVectorElementType(), - Mask->getType()->getVectorNumElements()); + Mask->getType()->getVectorElementCount()); InstructionList.push_back(I); break; } diff --git a/llvm/test/Bitcode/vscale-round-trip.ll b/llvm/test/Bitcode/vscale-round-trip.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Bitcode/vscale-round-trip.ll @@ -0,0 +1,49 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64" + +@important_val = extern_weak dso_local global i32, align 4 + +; CHECK-LABEL: define @const_shufflevector( +; CHECK: shufflevector ( + +define @const_shufflevector() { + ret shufflevector ( zeroinitializer, + undef, + zeroinitializer) +} + +; CHECK-LABEL: define @const_shufflevector_ex() +; CHECK: shufflevector ( + +define @const_shufflevector_ex() { + ret shufflevector ( zeroinitializer, + undef, + zeroinitializer) +} + +; CHECK-LABEL: define @non_const_shufflevector( +; CHECK: %res = shufflevector + +define @non_const_shufflevector( %lhs, + %rhs) { + %res = shufflevector %lhs, + %rhs, + zeroinitializer + + ret %res +} + +; CHECK-LABEL: define @const_select() +; CHECK: select ( + +define @const_select() { + ret select + ( insertelement + ( undef, + i1 icmp ne (i32* @important_val, i32* null), + i32 0), + zeroinitializer, + insertelement ( undef, i32 1, i32 0)) +}