Skip to content

Commit eac3396

Browse files
committed
!fixup address comments, thanks
1 parent a50d573 commit eac3396

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
@@ -1776,12 +1776,13 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
17761776
}
17771777

17781778
bool VectorCombine::scalarizeExtExtract(Instruction &I) {
1779-
if (!match(&I, m_ZExt(m_Value())))
1779+
auto *Ext = dyn_cast<ZExtInst>(&I);
1780+
if (!Ext)
17801781
return false;
17811782

1782-
// Try to convert a vector zext feeding only extracts to a set of scalar (Src
1783-
// << ExtIdx *Size) & (Size -1), if profitable.
1784-
auto *Ext = cast<ZExtInst>(&I);
1783+
// Try to convert a vector zext feeding only extracts to a set of scalar
1784+
// (Src << ExtIdx *Size) & (Size -1)
1785+
// if profitable .
17851786
auto *SrcTy = dyn_cast<FixedVectorType>(Ext->getOperand(0)->getType());
17861787
if (!SrcTy)
17871788
return false;
@@ -1822,21 +1823,20 @@ bool VectorCombine::scalarizeExtExtract(Instruction &I) {
18221823
return false;
18231824

18241825
Value *ScalarV = Ext->getOperand(0);
1825-
if (!isGuaranteedNotToBePoison(ScalarV, &AC))
1826+
if (!isGuaranteedNotToBePoison(ScalarV, &AC, dyn_cast<Instruction>(ScalarV),
1827+
&DT))
18261828
ScalarV = Builder.CreateFreeze(ScalarV);
18271829
ScalarV = Builder.CreateBitCast(
18281830
ScalarV,
18291831
IntegerType::get(SrcTy->getContext(), DL->getTypeSizeInBits(SrcTy)));
18301832
unsigned SrcEltSizeInBits = DL->getTypeSizeInBits(SrcTy->getElementType());
1831-
Value *EltBitMask =
1832-
ConstantInt::get(ScalarV->getType(), (1ull << SrcEltSizeInBits) - 1);
1833-
for (auto *U : to_vector(Ext->users())) {
1833+
unsigned EltBitMask = (1ull << SrcEltSizeInBits) - 1;
1834+
for (User *U : Ext->users()) {
18341835
auto *Extract = cast<ExtractElementInst>(U);
1835-
unsigned Idx =
1836+
uint64_t Idx =
18361837
cast<ConstantInt>(Extract->getIndexOperand())->getZExtValue();
1837-
auto *S = Builder.CreateLShr(
1838-
ScalarV, ConstantInt::get(ScalarV->getType(), Idx * SrcEltSizeInBits));
1839-
auto *A = Builder.CreateAnd(S, EltBitMask);
1838+
Value *S = Builder.CreateLShr(ScalarV, Idx * SrcEltSizeInBits);
1839+
Value *A = Builder.CreateAnd(S, EltBitMask);
18401840
U->replaceAllUsesWith(A);
18411841
}
18421842
return true;

0 commit comments

Comments
 (0)