[llvm] 0275165 - [RISCV] Verify that policy operands only exist on instructions with tied passthru operands

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 15:19:06 PDT 2022


Author: Philip Reames
Date: 2022-10-06T15:18:43-07:00
New Revision: 027516553da4d380a9a7ea673342dba61318cc47

URL: https://github.com/llvm/llvm-project/commit/027516553da4d380a9a7ea673342dba61318cc47
DIFF: https://github.com/llvm/llvm-project/commit/027516553da4d380a9a7ea673342dba61318cc47.diff

LOG: [RISCV] Verify that policy operands only exist on instructions with tied passthru operands

This is a non-trivial property relied upon by D135396. I wrote this to convince myself it was true.

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

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index 4ab53925799b..05b0c016c943 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -1266,6 +1266,15 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
       ErrInfo = "policy operand w/o VL operand?";
       return false;
     }
+
+    // VecPolicy operands can only exist on instructions with passthru/merge
+    // arguments. Note that not all arguments with passthru have vec policy
+    // operands- some instructions have implicit policies.
+    unsigned UseOpIdx;
+    if (!MI.isRegTiedToUseOperand(0, &UseOpIdx)) {
+      ErrInfo = "policy operand w/o tied operand?";
+      return false;
+    }
   }
 
   return true;


        


More information about the llvm-commits mailing list