Skip to content

Commit 75ed96d

Browse files
committed
!fixup address comments, thanks
1 parent a693db9 commit 75ed96d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,12 +1772,13 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
17721772
}
17731773

17741774
bool VectorCombine::scalarizeExtExtract(Instruction &I) {
1775-
if (!match(&I, m_ZExt(m_Value())))
1775+
auto *Ext = dyn_cast<ZExtInst>(&I);
1776+
if (!Ext)
17761777
return false;
17771778

1778-
// Try to convert a vector zext feeding only extracts to a set of scalar (Src
1779-
// << ExtIdx *Size) & (Size -1), if profitable.
1780-
auto *Ext = cast<ZExtInst>(&I);
1779+
// Try to convert a vector zext feeding only extracts to a set of scalar
1780+
// (Src << ExtIdx *Size) & (Size -1)
1781+
// if profitable .
17811782
auto *SrcTy = dyn_cast<FixedVectorType>(Ext->getOperand(0)->getType());
17821783
if (!SrcTy)
17831784
return false;
@@ -1818,21 +1819,20 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
18181819
return false;
18191820

18201821
Value *ScalarV = Ext->getOperand(0);
1821-
if (!isGuaranteedNotToBePoison(ScalarV, &AC))
1822+
if (!isGuaranteedNotToBePoison(ScalarV, &AC, dyn_cast<Instruction>(ScalarV),
1823+
&DT))
18221824
ScalarV = Builder.CreateFreeze(ScalarV);
18231825
ScalarV = Builder.CreateBitCast(
18241826
ScalarV,
18251827
IntegerType::get(SrcTy->getContext(), DL->getTypeSizeInBits(SrcTy)));
18261828
unsigned SrcEltSizeInBits = DL->getTypeSizeInBits(SrcTy->getElementType());
1827-
Value *EltBitMask =
1828-
ConstantInt::get(ScalarV->getType(), (1ull << SrcEltSizeInBits) - 1);
1829-
for (auto *U : to_vector(Ext->users())) {
1829+
unsigned EltBitMask = (1ull << SrcEltSizeInBits) - 1;
1830+
for (User *U : Ext->users()) {
18301831
auto *Extract = cast<ExtractElementInst>(U);
1831-
unsigned Idx =
1832+
uint64_t Idx =
18321833
cast<ConstantInt>(Extract->getIndexOperand())->getZExtValue();
1833-
auto *S = Builder.CreateLShr(
1834-
ScalarV, ConstantInt::get(ScalarV->getType(), Idx * SrcEltSizeInBits));
1835-
auto *A = Builder.CreateAnd(S, EltBitMask);
1834+
Value *S = Builder.CreateLShr(ScalarV, Idx * SrcEltSizeInBits);
1835+
Value *A = Builder.CreateAnd(S, EltBitMask);
18361836
U->replaceAllUsesWith(A);
18371837
}
18381838
return true;

0 commit comments

Comments
 (0)