[PATCH] D96529: [NFC][VPlan] Use VPUser to store block's predicate

Andrei Elovikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 11:01:45 PST 2021


a.elovikov created this revision.
a.elovikov added reviewers: fhahn, Ayal, gilr.
Herald added subscribers: tschuett, psnobl, rogfer01, bollu, hiraditya.
a.elovikov requested review of this revision.
Herald added subscribers: llvm-commits, vkmr.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96529

Files:
  llvm/lib/Transforms/Vectorize/VPlan.h


Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -408,8 +408,10 @@
   /// which is the branch condition.
   VPUser CondBitUser;
 
-  /// Current block predicate - null if the block does not need a predicate.
-  VPValue *Predicate = nullptr;
+  /// If the block is predicated, its predicate is stored as an operand of this
+  /// VPUser to maintain the def-use relations. Otherwise there is no operand
+  /// here.
+  VPUser PredicateUser;
 
   /// VPlan containing the block. Can only be set on the entry block of the
   /// plan.
@@ -579,11 +581,29 @@
       CondBitUser.addOperand(CV);
   }
 
-  VPValue *getPredicate() { return Predicate; }
+  VPValue *getPredicate() {
+    if (PredicateUser.getNumOperands())
+      return PredicateUser.getOperand(0);
+    return nullptr;
+  }
 
-  const VPValue *getPredicate() const { return Predicate; }
+  const VPValue *getPredicate() const {
+    if (PredicateUser.getNumOperands())
+      return PredicateUser.getOperand(0);
+    return nullptr;
+  }
 
-  void setPredicate(VPValue *Pred) { Predicate = Pred; }
+  void setPredicate(VPValue *Pred) {
+    if (!Pred) {
+      if (PredicateUser.getNumOperands() == 1)
+        PredicateUser.removeLastOperand();
+      return;
+    }
+    if (PredicateUser.getNumOperands() == 1)
+      PredicateUser.setOperand(0, Pred);
+    else
+      PredicateUser.addOperand(Pred);
+  }
 
   /// Set a given VPBlockBase \p Successor as the single successor of this
   /// VPBlockBase. This VPBlockBase is not added as predecessor of \p Successor.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96529.323080.patch
Type: text/x-patch
Size: 1680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210211/1df22291/attachment.bin>


More information about the llvm-commits mailing list