diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MachineVerifier.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 759201ed9dad..1fcbeeec6f64 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1739,7 +1739,7 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { } if (IndexOp.getImm() != 0 && - Src1Ty.getElementCount().getKnownMinValue() % IndexOp.getImm() != 0) { + IndexOp.getImm() % Src1Ty.getElementCount().getKnownMinValue() != 0) { report("Index must be a multiple of the second source vector's " "minimum vector length", MI); @@ -1778,10 +1778,25 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) { break; } - if (IndexOp.getImm() != 0 && - SrcTy.getElementCount().getKnownMinValue() % IndexOp.getImm() != 0) { - report("Index must be a multiple of the source vector's minimum vector " - "length", + if (SrcTy.isScalable() != DstTy.isScalable()) { + report("Vector types must both be fixed or both be scalable", MI); + break; + } + + uint64_t Idx = IndexOp.getImm(); + uint64_t DstMinLen = DstTy.getElementCount().getKnownMinValue(); + if (Idx % DstMinLen != 0) { + report("Index must be a multiple of the destination vector's minimum " + "vector length", + MI); + break; + } + + uint64_t SrcMinLen = SrcTy.getElementCount().getKnownMinValue(); + if (SrcTy.isScalable() == DstTy.isScalable() && + (Idx >= SrcMinLen || Idx + DstMinLen > SrcMinLen)) { + report("Source type and index must not cause extract to overrun to the " + "destination type", MI); break; } |
