diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -901,16 +901,17 @@ // Try and match an index sequence, which we can lower directly to the vid // instruction. An all-undef vector is matched by getSplatValue, above. - bool IsVID = true; - if (VT.isInteger()) + if (VT.isInteger()) { + bool IsVID = true; for (unsigned i = 0, e = Op.getNumOperands(); i < e && IsVID; i++) IsVID &= Op.getOperand(i).isUndef() || (isa(Op.getOperand(i)) && Op.getConstantOperandVal(i) == i); - if (IsVID) { - SDValue VID = DAG.getNode(RISCVISD::VID_VL, DL, ContainerVT, Mask, VL); - return convertFromScalableVector(VT, VID, DAG, Subtarget); + if (IsVID) { + SDValue VID = DAG.getNode(RISCVISD::VID_VL, DL, ContainerVT, Mask, VL); + return convertFromScalableVector(VT, VID, DAG, Subtarget); + } } return SDValue(); diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp-buildvec.ll @@ -0,0 +1,22 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py + +; RUN: llc -mtriple=riscv32 -target-abi=ilp32d -mattr=+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs -riscv-v-vector-bits-min=128 -riscv-v-fixed-length-vector-lmul-max=2 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX2 +; RUN: llc -mtriple=riscv64 -target-abi=lp64d -mattr=+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs -riscv-v-vector-bits-min=128 -riscv-v-fixed-length-vector-lmul-max=2 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX2 +; RUN: llc -mtriple=riscv32 -target-abi=ilp32d -mattr=+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs -riscv-v-vector-bits-min=128 -riscv-v-fixed-length-vector-lmul-max=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX1 +; RUN: llc -mtriple=riscv64 -target-abi=lp64d -mattr=+experimental-v,+experimental-zfh,+f,+d -verify-machineinstrs -riscv-v-vector-bits-min=128 -riscv-v-fixed-length-vector-lmul-max=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX1 + +; Tests that a floating-point build_vector doesn't try and generate a VID +; instruction +define void @buildvec_no_vid_v4f32(<4 x float>* %x) { +; CHECK-LABEL: buildvec_no_vid_v4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI0_0) +; CHECK-NEXT: addi a1, a1, %lo(.LCPI0_0) +; CHECK-NEXT: addi a2, zero, 4 +; CHECK-NEXT: vsetvli a2, a2, e32,m1,ta,mu +; CHECK-NEXT: vle32.v v25, (a1) +; CHECK-NEXT: vse32.v v25, (a0) +; CHECK-NEXT: ret + store <4 x float> , <4 x float>* %x + ret void +}