[llvm] ec228d7 - [InstCombine] Use SmallBitVector for convienently checking if all bits are set

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 11:38:04 PDT 2020


Author: Benjamin Kramer
Date: 2020-04-13T20:37:15+02:00
New Revision: ec228d722c08847c2b5bb12a99191d77df3374af

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

LOG: [InstCombine] Use SmallBitVector for convienently checking if all bits are set

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index f052f8e0100a..cf3b9dd84a95 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/VectorUtils.h"
@@ -771,7 +772,7 @@ static Instruction *foldInsSequenceIntoSplat(InsertElementInst &InsElt) {
 
   Value *SplatVal = InsElt.getOperand(1);
   InsertElementInst *CurrIE = &InsElt;
-  SmallVector<bool, 16> ElementPresent(NumElements, false);
+  SmallBitVector ElementPresent(NumElements, false);
   InsertElementInst *FirstIE = nullptr;
 
   // Walk the chain backwards, keeping track of which indices we inserted into,
@@ -803,7 +804,7 @@ static Instruction *foldInsSequenceIntoSplat(InsertElementInst &InsElt) {
   // TODO: If the base vector is not undef, it might be better to create a splat
   //       and then a select-shuffle (blend) with the base vector.
   if (!isa<UndefValue>(FirstIE->getOperand(0)))
-    if (any_of(ElementPresent, [](bool Present) { return !Present; }))
+    if (!ElementPresent.all())
       return nullptr;
 
   // Create the insert + shuffle.


        


More information about the llvm-commits mailing list