@@ -750,9 +750,9 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
750
750
// to ensure no extra casts would need to be inserted, so every DAG
751
751
// of connected values must have the same minimum bitwidth.
752
752
EquivalenceClasses<Value *> ECs;
753
- SmallVector<Value *, 16 > Worklist;
754
- SmallPtrSet<Value *, 4 > Roots;
755
- SmallPtrSet<Value *, 16 > Visited;
753
+ SmallVector<Instruction *, 16 > Worklist;
754
+ SmallPtrSet<Instruction *, 4 > Roots;
755
+ SmallPtrSet<Instruction *, 16 > Visited;
756
756
DenseMap<Value *, uint64_t > DBits;
757
757
SmallPtrSet<Instruction *, 4 > InstructionSet;
758
758
MapVector<Instruction *, uint64_t > MinBWs;
@@ -786,17 +786,12 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
786
786
787
787
// Now proceed breadth-first, unioning values together.
788
788
while (!Worklist.empty ()) {
789
- Value *Val = Worklist.pop_back_val ();
790
- Value *Leader = ECs.getOrInsertLeaderValue (Val );
789
+ Instruction *I = Worklist.pop_back_val ();
790
+ Value *Leader = ECs.getOrInsertLeaderValue (I );
791
791
792
- if (!Visited.insert (Val ).second )
792
+ if (!Visited.insert (I ).second )
793
793
continue ;
794
794
795
- // Non-instructions terminate a chain successfully.
796
- if (!isa<Instruction>(Val))
797
- continue ;
798
- Instruction *I = cast<Instruction>(Val);
799
-
800
795
// If we encounter a type that is larger than 64 bits, we can't represent
801
796
// it so bail out.
802
797
if (DB.getDemandedBits (I).getBitWidth () > 64 )
@@ -836,9 +831,10 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
836
831
// All bits demanded, no point continuing.
837
832
continue ;
838
833
839
- for (Value *O : cast<User>(I) ->operands ()) {
834
+ for (Value *O : I ->operands ()) {
840
835
ECs.unionSets (Leader, O);
841
- Worklist.push_back (O);
836
+ if (auto *OI = dyn_cast<Instruction>(O))
837
+ Worklist.push_back (OI);
842
838
}
843
839
}
844
840
@@ -879,7 +875,7 @@ llvm::computeMinimumValueSizes(ArrayRef<BasicBlock *> Blocks, DemandedBits &DB,
879
875
if (!MI)
880
876
continue ;
881
877
Type *Ty = M->getType ();
882
- if (Roots.count (M ))
878
+ if (Roots.count (MI ))
883
879
Ty = MI->getOperand (0 )->getType ();
884
880
885
881
if (MinBW >= Ty->getScalarSizeInBits ())
0 commit comments