Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions llvm/lib/Analysis/VectorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,9 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
// to ensure no extra casts would need to be inserted, so every DAG
// of connected values must have the same minimum bitwidth.
EquivalenceClasses<Value *> ECs;
SmallVector<Value *, 16> Worklist;
SmallPtrSet<Value *, 4> Roots;
SmallPtrSet<Value *, 16> Visited;
SmallVector<Instruction *, 16> Worklist;
SmallPtrSet<Instruction *, 4> Roots;
SmallPtrSet<Instruction *, 16> Visited;
DenseMap<Value *, uint64_t> DBits;
SmallPtrSet<Instruction *, 4> InstructionSet;
MapVector<Instruction *, uint64_t> MinBWs;
Expand Down Expand Up @@ -786,17 +786,12 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,

// Now proceed breadth-first, unioning values together.
while (!Worklist.empty()) {
Value *Val = Worklist.pop_back_val();
Value *Leader = ECs.getOrInsertLeaderValue(Val);
Instruction *I = Worklist.pop_back_val();
Value *Leader = ECs.getOrInsertLeaderValue(I);

if (!Visited.insert(Val).second)
if (!Visited.insert(I).second)
continue;

// Non-instructions terminate a chain successfully.
if (!isa<Instruction>(Val))
continue;
Instruction *I = cast<Instruction>(Val);

// If we encounter a type that is larger than 64 bits, we can't represent
// it so bail out.
if (DB.getDemandedBits(I).getBitWidth() > 64)
Expand Down Expand Up @@ -831,9 +826,10 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
// All bits demanded, no point continuing.
continue;

for (Value *O : cast<User>(I)->operands()) {
for (Value *O : I->operands()) {
ECs.unionSets(Leader, O);
Worklist.push_back(O);
if (auto *OI = dyn_cast<Instruction>(O))
Worklist.push_back(OI);
}
}

Expand Down Expand Up @@ -874,7 +870,7 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
if (!MI)
continue;
Type *Ty = M->getType();
if (Roots.count(M))
if (Roots.count(MI))
Ty = MI->getOperand(0)->getType();

if (MinBW >= Ty->getScalarSizeInBits())
Expand Down
Loading