Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1942,7 +1942,7 @@ SDValue SelectionDAG::getVScale(const SDLoc &DL, EVT VT, APInt MulImm, bool ConstantFold) { - assert(MulImm.getSignificantBits() <= VT.getSizeInBits() && + assert((MulImm.getSignificantBits() <= VT.getSizeInBits() || VT == MVT::i1) && "Immediate does not fit VT"); MulImm = MulImm.sextOrTrunc(VT.getSizeInBits()); Index: llvm/test/CodeGen/AArch64/sve-vscale.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-vscale.ll +++ llvm/test/CodeGen/AArch64/sve-vscale.ll @@ -101,6 +101,17 @@ ret i32 %1 } +define i1 @rdvl_i1() { +; CHECK-LABEL: rdvl_i1: +; CHECK: rdvl x8, #-1 +; CHECK-NEXT: asr x8, x8, #4 +; CHECK-NEXT: and w0, w8, #0x1 +; CHECK-NEXT: ret + %a = tail call i64 @llvm.vscale.i64() + %b = trunc i64 %a to i1 + ret i1 %b +} + ; ; CNTH ;