[RISCV] Add a fatal error if ISD::VSCALE is used with Zvl32b.
authorCraig Topper <craig.topper@sifive.com>
Mon, 31 Jan 2022 17:08:17 +0000 (09:08 -0800)
committerCraig Topper <craig.topper@sifive.com>
Mon, 31 Jan 2022 17:13:14 +0000 (09:13 -0800)
We convert VLEN to vscale by dividing by RVVBitsPerBlock which is
currently 64. This is only correct if VLEN is evenly divisible by
64. With only Zvl32b we can't assume that.

This patch adds a fatal_error to prevent generating code that may
be broken.

We probably need to look at how we size stack frame objects too.

Reviewed By: frasercrmck

Differential Revision: https://reviews.llvm.org/D118583

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

index de24058..72bae06 100644 (file)
@@ -3076,6 +3076,8 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
     // minimum size. e.g. <vscale x 2 x i32>. VLENB is in bytes so we calculate
     // vscale as VLENB / 8.
     static_assert(RISCV::RVVBitsPerBlock == 64, "Unexpected bits per block!");
+    if (Subtarget.getMinVLen() < RISCV::RVVBitsPerBlock)
+      report_fatal_error("Support for VLEN==32 is incomplete.");
     if (isa<ConstantSDNode>(Op.getOperand(0))) {
       // We assume VLENB is a multiple of 8. We manually choose the best shift
       // here because SimplifyDemandedBits isn't always able to simplify it.