Skip to content

Commit

Permalink
[InstCombine] Use SmallBitVector for convienently checking if all bit…
Browse files Browse the repository at this point in the history
…s are set
  • Loading branch information
d0k committed Apr 13, 2020
1 parent 42ada5f commit ec228d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ec228d7

Please sign in to comment.