[llvm] [NVPTX] Teach NVPTX about predicates (PR #67468)

Fraser Cormack via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 03:03:07 PDT 2024


================
@@ -92,50 +103,62 @@ bool NVPTXInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
                                    MachineBasicBlock *&FBB,
                                    SmallVectorImpl<MachineOperand> &Cond,
                                    bool AllowModify) const {
+  auto getBranchTarget = [](MachineInstr &MI) {
+    assert(MI.isBranch());
+    return MI.getOperand(0).getMBB();
+  };
+  auto getPred = [](MachineInstr &MI) {
+    assert(MI.isPredicable());
----------------
frasercrmck wrote:

AFAICT, if `defaultPreds` is 0 in TableGen, then the MI would be `isPredicable` but not have the predicate operands, in which case `MI.getNumOperands() - 2` would do the wrong thing.

Do we need a more robust check for whether a MI has predicate operand?

https://github.com/llvm/llvm-project/pull/67468


More information about the llvm-commits mailing list