aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineVerifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineVerifier.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 759201e..6eed73c 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -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;
}