diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index 6448c372f5d5d..02f93d3fd1b4c 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -750,9 +750,9 @@ llvm::computeMinimumValueSizes(ArrayRef 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 ECs; - SmallVector Worklist; - SmallPtrSet Roots; - SmallPtrSet Visited; + SmallVector Worklist; + SmallPtrSet Roots; + SmallPtrSet Visited; DenseMap DBits; SmallPtrSet InstructionSet; MapVector MinBWs; @@ -786,17 +786,12 @@ llvm::computeMinimumValueSizes(ArrayRef 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(Val)) - continue; - Instruction *I = cast(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) @@ -831,9 +826,10 @@ llvm::computeMinimumValueSizes(ArrayRef Blocks, DemandedBits &DB, // All bits demanded, no point continuing. continue; - for (Value *O : cast(I)->operands()) { + for (Value *O : I->operands()) { ECs.unionSets(Leader, O); - Worklist.push_back(O); + if (auto *OI = dyn_cast(O)) + Worklist.push_back(OI); } } @@ -874,7 +870,7 @@ llvm::computeMinimumValueSizes(ArrayRef 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())