[PATCH] D80110: [VPlan] Remove unique_ptr from VPBranchOnRecipeMask (NFC).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 02:05:56 PDT 2020


fhahn created this revision.
fhahn added reviewers: Ayal, gilr, rengolin.
Herald added subscribers: vkmr, psnobl, rogfer01, rkruppe, bollu, hiraditya.
Herald added a project: LLVM.

We can remove a dynamic memory allocation, by checking the number of
operands: no operands = all true, 1 operand = mask.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80110

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  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
@@ -1063,12 +1063,12 @@
 
 /// A recipe for generating conditional branches on the bits of a mask.
 class VPBranchOnMaskRecipe : public VPRecipeBase {
-  std::unique_ptr<VPUser> User;
+  VPUser User;
 
 public:
   VPBranchOnMaskRecipe(VPValue *BlockInMask) : VPRecipeBase(VPBranchOnMaskSC) {
     if (BlockInMask) // nullptr means all-one mask.
-      User.reset(new VPUser({BlockInMask}));
+      User.addOperand(BlockInMask);
   }
 
   /// Method to support type inquiry through isa, cast, and dyn_cast.
@@ -1084,8 +1084,8 @@
   void print(raw_ostream &O, const Twine &Indent,
              VPSlotTracker &SlotTracker) const override {
     O << " +\n" << Indent << "\"BRANCH-ON-MASK ";
-    if (User)
-      User->getOperand(0)->print(O, SlotTracker);
+    if (User.getNumOperands() != 0)
+      User.getOperand(0)->print(O, SlotTracker);
     else
       O << " All-One";
     O << "\\l\"";
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7525,10 +7525,10 @@
   unsigned Lane = State.Instance->Lane;
 
   Value *ConditionBit = nullptr;
-  if (!User) // Block in mask is all-one.
+  if (User.getNumOperands() == 0) // Block in mask is all-one.
     ConditionBit = State.Builder.getTrue();
   else {
-    VPValue *BlockInMask = User->getOperand(0);
+    VPValue *BlockInMask = User.getOperand(0);
     ConditionBit = State.get(BlockInMask, Part);
     if (ConditionBit->getType()->isVectorTy())
       ConditionBit = State.Builder.CreateExtractElement(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80110.264558.patch
Type: text/x-patch
Size: 1835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/dbc42c6b/attachment.bin>


More information about the llvm-commits mailing list