@@ -628,18 +628,15 @@ std::vector<Chain> Vectorizer::splitChainByContiguity(Chain &C) {
628628
629629 unsigned ElemBytes = DL.getTypeStoreSize (getChainElemTy (C));
630630 APInt PrevReadEnd = C[0 ].OffsetFromLeader +
631- DL.getTypeSizeInBits (getLoadStoreType (&*C[0 ].Inst )) / 8 ;
631+ DL.getTypeStoreSize (getLoadStoreType (&*C[0 ].Inst ));
632632 for (auto It = std::next (C.begin ()), End = C.end (); It != End; ++It) {
633633 // `prev` accesses offsets [PrevDistFromBase, PrevReadEnd).
634634 auto &CurChain = Ret.back ();
635- unsigned SzBits = DL.getTypeSizeInBits (getLoadStoreType (&*It->Inst ));
636- assert (SzBits % 8 == 0 && " Non-byte sizes should have been filtered out by "
637- " collectEquivalenceClass" );
635+ unsigned SzBytes = DL.getTypeStoreSize (getLoadStoreType (&*It->Inst ));
638636
639637 // Add this instruction to the end of the current chain, or start a new one.
640- uint64_t SzBytes = SzBits / 8 ;
641638 assert (SzBytes % ElemBytes == 0 );
642- APInt ReadEnd = It->OffsetFromLeader + SzBits / 8 ;
639+ APInt ReadEnd = It->OffsetFromLeader + SzBytes ;
643640 // Allow redundancy: partial or full overlap counts as contiguous.
644641 bool AreContiguous = false ;
645642 if (It->OffsetFromLeader .sle (PrevReadEnd)) {
@@ -886,12 +883,12 @@ bool Vectorizer::vectorizeChain(Chain &C) {
886883 Type *VecElemTy = getChainElemTy (C);
887884 bool IsLoadChain = isa<LoadInst>(C[0 ].Inst );
888885 unsigned AS = getLoadStoreAddressSpace (C[0 ].Inst );
889- int BytesAdded = DL.getTypeSizeInBits (getLoadStoreType (&*C[0 ].Inst )) / 8 ;
886+ unsigned BytesAdded = DL.getTypeStoreSize (getLoadStoreType (&*C[0 ].Inst ));
890887 APInt PrevReadEnd = C[0 ].OffsetFromLeader + BytesAdded;
891- int ChainBytes = BytesAdded;
888+ unsigned ChainBytes = BytesAdded;
892889 for (auto It = std::next (C.begin ()), End = C.end (); It != End; ++It) {
893- unsigned SzBits = DL.getTypeSizeInBits (getLoadStoreType (&*It->Inst ));
894- APInt ReadEnd = It->OffsetFromLeader + SzBits / 8 ;
890+ unsigned SzBytes = DL.getTypeStoreSize (getLoadStoreType (&*It->Inst ));
891+ APInt ReadEnd = It->OffsetFromLeader + SzBytes ;
895892 // Update ChainBytes considering possible overlap.
896893 BytesAdded =
897894 PrevReadEnd.sle (ReadEnd) ? (ReadEnd - PrevReadEnd).getSExtValue () : 0 ;
@@ -902,7 +899,7 @@ bool Vectorizer::vectorizeChain(Chain &C) {
902899 assert (ChainBytes % DL.getTypeStoreSize (VecElemTy) == 0 );
903900 // VecTy is a power of 2 and 1 byte at smallest, but VecElemTy may be smaller
904901 // than 1 byte (e.g. VecTy == <32 x i1>).
905- unsigned NumElem = 8 * ChainBytes / DL.getTypeSizeInBits (VecElemTy);
902+ unsigned NumElem = ChainBytes / DL.getTypeStoreSize (VecElemTy);
906903 Type *VecTy = FixedVectorType::get (VecElemTy, NumElem);
907904
908905 Align Alignment = getLoadStoreAlignment (C[0 ].Inst );
@@ -945,7 +942,7 @@ bool Vectorizer::vectorizeChain(Chain &C) {
945942 Value *V;
946943 Type *T = getLoadStoreType (I);
947944 int EOffset = (E.OffsetFromLeader - C[0 ].OffsetFromLeader ).getSExtValue ();
948- int VecIdx = 8 * EOffset / DL.getTypeSizeInBits (VecElemTy);
945+ int VecIdx = EOffset / DL.getTypeStoreSize (VecElemTy);
949946 if (auto *VT = dyn_cast<FixedVectorType>(T)) {
950947 auto Mask = llvm::to_vector<8 >(
951948 llvm::seq<int >(VecIdx, VecIdx + VT->getNumElements ()));
0 commit comments