<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Philip,</p>
<p>Thanks, will do this next time.<br>
</p>
<pre class="moz-signature" cols="72">-------------
Best regards,
Alexey Bataev</pre>
<div class="moz-cite-prefix">29.01.2018 12:40, Philip Reames пишет:<br>
</div>
<blockquote type="cite"
cite="mid:efd6dee9-881f-c31e-221f-800c13330ffb@philipreames.com">Alexey,
<br>
<br>
It is customary when reverting a patch to reply to the commit
thread stating the patch has been reverted and with what commit
ID. It is also customary to include a brief summary of the bugs
fixed when resubmitting. This makes it easier for the broader
community to follow along and see the progress being made.
<br>
<br>
Philip
<br>
<br>
<br>
On 01/25/2018 09:28 AM, Alexey Bataev via llvm-commits wrote:
<br>
<blockquote type="cite">Author: abataev
<br>
Date: Thu Jan 25 09:28:12 2018
<br>
New Revision: 323447
<br>
<br>
URL:
<a class="moz-txt-link-freetext" href="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%3Frev%3D323447%26view%3Drev&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=mvrIotuGH63pZLvrxjMYqfgaRVHDtE51kdUXq0faxRY%3D&reserved=0">https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%3Frev%3D323447%26view%3Drev&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=mvrIotuGH63pZLvrxjMYqfgaRVHDtE51kdUXq0faxRY%3D&reserved=0</a><br>
Log:
<br>
Revert "[SLP] Fix for PR32086: Count InsertElementInstr of the
same elements as shuffle."
<br>
<br>
This reverts commit r323441 to fix buildbots.
<br>
<br>
Modified:
<br>
llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
<br>
llvm/trunk/test/Transforms/SLPVectorizer/X86/PR32086.ll
<br>
llvm/trunk/test/Transforms/SLPVectorizer/X86/blending-shuffle.ll
<br>
llvm/trunk/test/Transforms/SLPVectorizer/X86/hoist.ll
<br>
<br>
Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
<br>
URL:
<a class="moz-txt-link-freetext" href="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Flib%2FTransforms%2FVectorize%2FSLPVectorizer.cpp%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=eVEC4BxzFysQxlVx5tkiAsOQrKbkjNClD6KMjzvY0L4%3D&reserved=0">https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Flib%2FTransforms%2FVectorize%2FSLPVectorizer.cpp%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=eVEC4BxzFysQxlVx5tkiAsOQrKbkjNClD6KMjzvY0L4%3D&reserved=0</a><br>
==============================================================================
<br>
--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp
(original)
<br>
+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Thu
Jan 25 09:28:12 2018
<br>
@@ -662,9 +662,13 @@ private:
<br>
/// Vectorize a single entry in the tree, starting in \p VL.
<br>
Value *vectorizeTree(ArrayRef<Value *> VL);
<br>
+ /// \returns the pointer to the vectorized value if \p VL
is already
<br>
+ /// vectorized, or NULL. They may happen in cycles.
<br>
+ Value *alreadyVectorized(ArrayRef<Value *> VL, Value
*OpValue) const;
<br>
+
<br>
/// \returns the scalarization cost for this type.
Scalarization in this
<br>
/// context means the creation of vectors from a group of
scalars.
<br>
- int getGatherCost(Type *Ty, const DenseSet<unsigned>
&ShuffledIndices);
<br>
+ int getGatherCost(Type *Ty);
<br>
/// \returns the scalarization cost for this list of
values. Assuming that
<br>
/// this subtree gets vectorized, we may need to extract the
values from the
<br>
@@ -698,12 +702,8 @@ private:
<br>
/// \returns true if the scalars in VL are equal to this
entry.
<br>
bool isSame(ArrayRef<Value *> VL) const {
<br>
- if (VL.size() == Scalars.size())
<br>
- return std::equal(VL.begin(), VL.end(),
Scalars.begin());
<br>
- return VL.size() == ReuseShuffleIndices.size() &&
<br>
- std::equal(
<br>
- VL.begin(), VL.end(),
ReuseShuffleIndices.begin(),
<br>
- [this](Value *V, unsigned Idx) { return V ==
Scalars[Idx]; });
<br>
+ assert(VL.size() == Scalars.size() && "Invalid
size");
<br>
+ return std::equal(VL.begin(), VL.end(), Scalars.begin());
<br>
}
<br>
/// A vector of scalars.
<br>
@@ -715,9 +715,6 @@ private:
<br>
/// Do we need to gather this sequence ?
<br>
bool NeedToGather = false;
<br>
- /// Does this sequence require some shuffling?
<br>
- SmallVector<unsigned, 4> ReuseShuffleIndices;
<br>
-
<br>
/// Points back to the VectorizableTree.
<br>
///
<br>
/// Only used for Graphviz right now. Unfortunately
GraphTrait::NodeRef has
<br>
@@ -732,15 +729,13 @@ private:
<br>
};
<br>
/// Create a new VectorizableTree entry.
<br>
- void newTreeEntry(ArrayRef<Value *> VL, bool
Vectorized, int &UserTreeIdx,
<br>
- ArrayRef<unsigned>
ReuseShuffleIndices = None) {
<br>
+ TreeEntry *newTreeEntry(ArrayRef<Value *> VL, bool
Vectorized,
<br>
+ int &UserTreeIdx) {
<br>
VectorizableTree.emplace_back(VectorizableTree);
<br>
int idx = VectorizableTree.size() - 1;
<br>
TreeEntry *Last = &VectorizableTree[idx];
<br>
Last->Scalars.insert(Last->Scalars.begin(),
VL.begin(), VL.end());
<br>
Last->NeedToGather = !Vectorized;
<br>
-
Last->ReuseShuffleIndices.append(ReuseShuffleIndices.begin(),
<br>
-
ReuseShuffleIndices.end());
<br>
if (Vectorized) {
<br>
for (int i = 0, e = VL.size(); i != e; ++i) {
<br>
assert(!getTreeEntry(VL[i]) && "Scalar already
in tree!");
<br>
@@ -753,6 +748,7 @@ private:
<br>
if (UserTreeIdx >= 0)
<br>
Last->UserTreeIndices.push_back(UserTreeIdx);
<br>
UserTreeIdx = idx;
<br>
+ return Last;
<br>
}
<br>
/// -- Vectorization State --
<br>
@@ -766,6 +762,13 @@ private:
<br>
return nullptr;
<br>
}
<br>
+ const TreeEntry *getTreeEntry(Value *V) const {
<br>
+ auto I = ScalarToTreeEntry.find(V);
<br>
+ if (I != ScalarToTreeEntry.end())
<br>
+ return &VectorizableTree[I->second];
<br>
+ return nullptr;
<br>
+ }
<br>
+
<br>
/// Maps a specific scalar to its tree entry.
<br>
SmallDenseMap<Value*, int> ScalarToTreeEntry;
<br>
@@ -1429,11 +1432,13 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
// Check if this is a duplicate of another entry.
<br>
if (TreeEntry *E = getTreeEntry(S.OpValue)) {
<br>
- DEBUG(dbgs() << "SLP: \tChecking bundle: " <<
*S.OpValue << ".\n");
<br>
- if (!E->isSame(VL)) {
<br>
- DEBUG(dbgs() << "SLP: Gathering due to partial
overlap.\n");
<br>
- newTreeEntry(VL, false, UserTreeIdx);
<br>
- return;
<br>
+ for (unsigned i = 0, e = VL.size(); i != e; ++i) {
<br>
+ DEBUG(dbgs() << "SLP: \tChecking bundle: " <<
*VL[i] << ".\n");
<br>
+ if (E->Scalars[i] != VL[i]) {
<br>
+ DEBUG(dbgs() << "SLP: Gathering due to partial
overlap.\n");
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
+ return;
<br>
+ }
<br>
}
<br>
// Record the reuse of the tree node. FIXME, currently
this is only used to
<br>
// properly draw the graph rather than for the actual
vectorization.
<br>
@@ -1479,26 +1484,13 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
}
<br>
// Check that every instruction appears once in this
bundle.
<br>
- SmallVector<unsigned, 4> ReuseShuffleIndicies;
<br>
- SmallVector<Value *, 4> UniqueValues;
<br>
- DenseMap<Value *, unsigned> UniquePositions;
<br>
- for (Value *V : VL) {
<br>
- auto Res = UniquePositions.try_emplace(V,
UniqueValues.size());
<br>
- ReuseShuffleIndicies.emplace_back(Res.first->second);
<br>
- if (Res.second)
<br>
- UniqueValues.emplace_back(V);
<br>
- }
<br>
- if (UniqueValues.size() == VL.size()) {
<br>
- ReuseShuffleIndicies.clear();
<br>
- } else {
<br>
- DEBUG(dbgs() << "SLP: Shuffle for reused
scalars.\n");
<br>
- if (UniqueValues.size() <= 1 ||
!llvm::isPowerOf2_32(UniqueValues.size())) {
<br>
- DEBUG(dbgs() << "SLP: Scalar used twice in
bundle.\n");
<br>
- newTreeEntry(VL, false, UserTreeIdx);
<br>
- return;
<br>
- }
<br>
- VL = UniqueValues;
<br>
- }
<br>
+ for (unsigned i = 0, e = VL.size(); i < e; ++i)
<br>
+ for (unsigned j = i + 1; j < e; ++j)
<br>
+ if (VL[i] == VL[j]) {
<br>
+ DEBUG(dbgs() << "SLP: Scalar used twice in
bundle.\n");
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
+ return;
<br>
+ }
<br>
auto &BSRef = BlocksSchedules[BB];
<br>
if (!BSRef)
<br>
@@ -1506,12 +1498,12 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
BlockScheduling &BS = *BSRef.get();
<br>
- if (!BS.tryScheduleBundle(VL, this, VL0)) {
<br>
+ if (!BS.tryScheduleBundle(VL, this, S.OpValue)) {
<br>
DEBUG(dbgs() << "SLP: We are not able to schedule
this bundle!\n");
<br>
assert((!BS.getScheduleData(VL0) ||
<br>
!BS.getScheduleData(VL0)->isPartOfBundle())
&&
<br>
"tryScheduleBundle should cancelScheduling on
failure");
<br>
- newTreeEntry(VL, false, UserTreeIdx, ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
return;
<br>
}
<br>
DEBUG(dbgs() << "SLP: We are able to schedule this
bundle.\n");
<br>
@@ -1530,12 +1522,12 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
if (Term) {
<br>
DEBUG(dbgs() << "SLP: Need to swizzle
PHINodes (TerminatorInst use).\n");
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
return;
<br>
}
<br>
}
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a vector of
PHINodes.\n");
<br>
for (unsigned i = 0, e =
PH->getNumIncomingValues(); i < e; ++i) {
<br>
@@ -1553,7 +1545,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
case Instruction::ExtractElement: {
<br>
bool Reuse = canReuseExtract(VL, VL0);
<br>
if (Reuse) {
<br>
- DEBUG(dbgs() << "SLP: Reusing or shuffling
extract sequence.\n");
<br>
+ DEBUG(dbgs() << "SLP: Reusing extract
sequence.\n");
<br>
++NumOpsWantToKeepOrder[S.Opcode];
<br>
} else {
<br>
SmallVector<Value *, 4> ReverseVL(VL.rbegin(),
VL.rend());
<br>
@@ -1561,7 +1553,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
--NumOpsWantToKeepOrder[S.Opcode];
<br>
BS.cancelScheduling(VL, VL0);
<br>
}
<br>
- newTreeEntry(VL, Reuse, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, Reuse, UserTreeIdx);
<br>
return;
<br>
}
<br>
case Instruction::Load: {
<br>
@@ -1576,7 +1568,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
if (DL->getTypeSizeInBits(ScalarTy) !=
<br>
DL->getTypeAllocSizeInBits(ScalarTy)) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: Gathering loads of
non-packed type.\n");
<br>
return;
<br>
}
<br>
@@ -1587,7 +1579,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
LoadInst *L = cast<LoadInst>(VL[i]);
<br>
if (!L->isSimple()) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: Gathering non-simple
loads.\n");
<br>
return;
<br>
}
<br>
@@ -1609,7 +1601,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
if (Consecutive) {
<br>
++NumOpsWantToKeepOrder[S.Opcode];
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a vector of
loads.\n");
<br>
return;
<br>
}
<br>
@@ -1624,7 +1616,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
}
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
if (ReverseConsecutive) {
<br>
--NumOpsWantToKeepOrder[S.Opcode];
<br>
@@ -1651,12 +1643,12 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
Type *Ty =
cast<Instruction>(VL[i])->getOperand(0)->getType();
<br>
if (Ty != SrcTy || !isValidElementType(Ty)) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: Gathering casts with
different src types.\n");
<br>
return;
<br>
}
<br>
}
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a vector of
casts.\n");
<br>
for (unsigned i = 0, e = VL0->getNumOperands(); i
< e; ++i) {
<br>
@@ -1679,13 +1671,13 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
if (Cmp->getPredicate() != P0 ||
<br>
Cmp->getOperand(0)->getType() != ComparedTy)
{
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: Gathering cmp with
different predicate.\n");
<br>
return;
<br>
}
<br>
}
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a vector of
compares.\n");
<br>
for (unsigned i = 0, e = VL0->getNumOperands(); i
< e; ++i) {
<br>
@@ -1717,7 +1709,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
case Instruction::And:
<br>
case Instruction::Or:
<br>
case Instruction::Xor:
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a vector of bin
op.\n");
<br>
// Sort operands of the instructions so that each side
is more likely to
<br>
@@ -1746,7 +1738,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
if
(cast<Instruction>(VL[j])->getNumOperands() != 2) {
<br>
DEBUG(dbgs() << "SLP: not-vectorizable GEP
(nested indexes).\n");
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
return;
<br>
}
<br>
}
<br>
@@ -1759,7 +1751,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
if (Ty0 != CurTy) {
<br>
DEBUG(dbgs() << "SLP: not-vectorizable GEP
(different types).\n");
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
return;
<br>
}
<br>
}
<br>
@@ -1771,12 +1763,12 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
DEBUG(
<br>
dbgs() << "SLP: not-vectorizable GEP
(non-constant indexes).\n");
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
return;
<br>
}
<br>
}
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a vector of GEPs.\n");
<br>
for (unsigned i = 0, e = 2; i < e; ++i) {
<br>
ValueList Operands;
<br>
@@ -1793,12 +1785,12 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
for (unsigned i = 0, e = VL.size() - 1; i < e; ++i)
<br>
if (!isConsecutiveAccess(VL[i], VL[i + 1], *DL, *SE))
{
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: Non-consecutive
store.\n");
<br>
return;
<br>
}
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a vector of
stores.\n");
<br>
ValueList Operands;
<br>
@@ -1816,7 +1808,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI);
<br>
if (!isTriviallyVectorizable(ID)) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: Non-vectorizable
call.\n");
<br>
return;
<br>
}
<br>
@@ -1830,7 +1822,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
getVectorIntrinsicIDForCall(CI2, TLI) != ID ||
<br>
!CI->hasIdenticalOperandBundleSchema(*CI2)) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: mismatched calls:"
<< *CI << "!=" << *VL[i]
<br>
<< "\n");
<br>
return;
<br>
@@ -1841,7 +1833,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
Value *A1J = CI2->getArgOperand(1);
<br>
if (A1I != A1J) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: mismatched arguments
in call:" << *CI
<br>
<< " argument "<<
A1I<<"!=" << A1J
<br>
<< "\n");
<br>
@@ -1854,14 +1846,14 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
CI->op_begin() +
CI->getBundleOperandsEndIndex(),
<br>
CI2->op_begin() +
CI2->getBundleOperandsStartIndex())) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: mismatched bundle
operands in calls:" << *CI << "!="
<br>
<< *VL[i] << '\n');
<br>
return;
<br>
}
<br>
}
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
for (unsigned i = 0, e = CI->getNumArgOperands(); i
!= e; ++i) {
<br>
ValueList Operands;
<br>
// Prepare the operand vector.
<br>
@@ -1878,11 +1870,11 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
// then do not vectorize this instruction.
<br>
if (!S.IsAltShuffle) {
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: ShuffleVector are not
vectorized.\n");
<br>
return;
<br>
}
<br>
- newTreeEntry(VL, true, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, true, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: added a ShuffleVector
op.\n");
<br>
// Reorder operands if reordering would enable
vectorization.
<br>
@@ -1906,7 +1898,7 @@ void
BoUpSLP::buildTree_rec(ArrayRef<Val
<br>
default:
<br>
BS.cancelScheduling(VL, VL0);
<br>
- newTreeEntry(VL, false, UserTreeIdx,
ReuseShuffleIndicies);
<br>
+ newTreeEntry(VL, false, UserTreeIdx);
<br>
DEBUG(dbgs() << "SLP: Gathering unknown
instruction.\n");
<br>
return;
<br>
}
<br>
@@ -1999,22 +1991,13 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
VecTy = VectorType::get(
<br>
IntegerType::get(F->getContext(),
MinBWs[VL[0]].first), VL.size());
<br>
- unsigned ReuseShuffleNumbers =
E->ReuseShuffleIndices.size();
<br>
- bool NeedToShuffleReuses =
!E->ReuseShuffleIndices.empty();
<br>
- int ReuseShuffleCost = 0;
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost =
<br>
-
TTI->getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc,
VecTy);
<br>
- }
<br>
if (E->NeedToGather) {
<br>
if (allConstant(VL))
<br>
return 0;
<br>
if (isSplat(VL)) {
<br>
- return ReuseShuffleCost +
<br>
-
TTI->getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy,
0);
<br>
+ return
TTI->getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy,
0);
<br>
}
<br>
- if (getSameOpcode(VL).Opcode == Instruction::ExtractElement
&&
<br>
- allSameType(VL) && allSameBlock(VL)) {
<br>
+ if (getSameOpcode(VL).Opcode ==
Instruction::ExtractElement) {
<br>
Optional<TargetTransformInfo::ShuffleKind>
ShuffleKind = isShuffle(VL);
<br>
if (ShuffleKind.hasValue()) {
<br>
int Cost =
TTI->getShuffleCost(ShuffleKind.getValue(), VecTy);
<br>
@@ -2031,10 +2014,10 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
IO->getZExtValue());
<br>
}
<br>
}
<br>
- return ReuseShuffleCost + Cost;
<br>
+ return Cost;
<br>
}
<br>
}
<br>
- return ReuseShuffleCost + getGatherCost(VL);
<br>
+ return getGatherCost(E->Scalars);
<br>
}
<br>
InstructionsState S = getSameOpcode(VL);
<br>
assert(S.Opcode && allSameType(VL) &&
allSameBlock(VL) && "Invalid VL");
<br>
@@ -2047,36 +2030,8 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
case Instruction::ExtractValue:
<br>
case Instruction::ExtractElement:
<br>
- if (NeedToShuffleReuses) {
<br>
- unsigned Idx = 0;
<br>
- for (unsigned I : E->ReuseShuffleIndices) {
<br>
- if (ShuffleOrOp == Instruction::ExtractElement) {
<br>
- auto *IO = cast<ConstantInt>(
<br>
-
cast<ExtractElementInst>(VL[I])->getIndexOperand());
<br>
- Idx = IO->getZExtValue();
<br>
- ReuseShuffleCost -= TTI->getVectorInstrCost(
<br>
- Instruction::ExtractElement, VecTy, Idx);
<br>
- } else {
<br>
- ReuseShuffleCost -= TTI->getVectorInstrCost(
<br>
- Instruction::ExtractElement, VecTy, Idx);
<br>
- ++Idx;
<br>
- }
<br>
- }
<br>
- Idx = ReuseShuffleNumbers;
<br>
- for (Value *V : VL) {
<br>
- if (ShuffleOrOp == Instruction::ExtractElement) {
<br>
- auto *IO = cast<ConstantInt>(
<br>
-
cast<ExtractElementInst>(V)->getIndexOperand());
<br>
- Idx = IO->getZExtValue();
<br>
- } else {
<br>
- --Idx;
<br>
- }
<br>
- ReuseShuffleCost +=
<br>
-
TTI->getVectorInstrCost(Instruction::ExtractElement, VecTy,
Idx);
<br>
- }
<br>
- }
<br>
if (canReuseExtract(VL, S.OpValue)) {
<br>
- int DeadCost = ReuseShuffleCost;
<br>
+ int DeadCost = 0;
<br>
for (unsigned i = 0, e = VL.size(); i < e; ++i) {
<br>
Instruction *E = cast<Instruction>(VL[i]);
<br>
// If all users are going to be vectorized,
instruction can be
<br>
@@ -2084,12 +2039,12 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
// The same, if have only one user, it will be
vectorized for sure.
<br>
if (areAllUsersVectorized(E))
<br>
// Take credit for instruction that will become
dead.
<br>
- DeadCost -=
<br>
+ DeadCost +=
<br>
TTI->getVectorInstrCost(Instruction::ExtractElement, VecTy,
i);
<br>
}
<br>
- return DeadCost;
<br>
+ return -DeadCost;
<br>
}
<br>
- return ReuseShuffleCost + getGatherCost(VL);
<br>
+ return getGatherCost(VecTy);
<br>
case Instruction::ZExt:
<br>
case Instruction::SExt:
<br>
@@ -2104,11 +2059,6 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
case Instruction::FPTrunc:
<br>
case Instruction::BitCast: {
<br>
Type *SrcTy = VL0->getOperand(0)->getType();
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost -=
<br>
- (ReuseShuffleNumbers - VL.size()) *
<br>
- TTI->getCastInstrCost(S.Opcode, ScalarTy, SrcTy,
VL0);
<br>
- }
<br>
// Calculate the cost of this instruction.
<br>
int ScalarCost = VL.size() *
TTI->getCastInstrCost(VL0->getOpcode(),
<br>
@@ -2117,26 +2067,19 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
VectorType *SrcVecTy = VectorType::get(SrcTy,
VL.size());
<br>
int VecCost = 0;
<br>
// Check if the values are candidates to demote.
<br>
- if (!MinBWs.count(VL0) || VecTy != SrcVecTy) {
<br>
- VecCost = ReuseShuffleCost +
<br>
- TTI->getCastInstrCost(VL0->getOpcode(),
VecTy, SrcVecTy, VL0);
<br>
- }
<br>
+ if (!MinBWs.count(VL0) || VecTy != SrcVecTy)
<br>
+ VecCost = TTI->getCastInstrCost(VL0->getOpcode(),
VecTy, SrcVecTy, VL0);
<br>
return VecCost - ScalarCost;
<br>
}
<br>
case Instruction::FCmp:
<br>
case Instruction::ICmp:
<br>
case Instruction::Select: {
<br>
// Calculate the cost of this instruction.
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost -= (ReuseShuffleNumbers - VL.size()) *
<br>
-
TTI->getCmpSelInstrCost(S.Opcode, ScalarTy,
<br>
-
Builder.getInt1Ty(), VL0);
<br>
- }
<br>
VectorType *MaskTy =
VectorType::get(Builder.getInt1Ty(), VL.size());
<br>
int ScalarCost = VecTy->getNumElements() *
<br>
TTI->getCmpSelInstrCost(S.Opcode, ScalarTy,
Builder.getInt1Ty(), VL0);
<br>
int VecCost = TTI->getCmpSelInstrCost(S.Opcode,
VecTy, MaskTy, VL0);
<br>
- return ReuseShuffleCost + VecCost - ScalarCost;
<br>
+ return VecCost - ScalarCost;
<br>
}
<br>
case Instruction::Add:
<br>
case Instruction::FAdd:
<br>
@@ -2194,19 +2137,13 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
Op2VP = TargetTransformInfo::OP_PowerOf2;
<br>
SmallVector<const Value *, 4>
Operands(VL0->operand_values());
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost -=
<br>
- (ReuseShuffleNumbers - VL.size()) *
<br>
- TTI->getArithmeticInstrCost(S.Opcode, ScalarTy,
Op1VK, Op2VK, Op1VP,
<br>
- Op2VP, Operands);
<br>
- }
<br>
int ScalarCost =
<br>
VecTy->getNumElements() *
<br>
TTI->getArithmeticInstrCost(S.Opcode, ScalarTy,
Op1VK, Op2VK, Op1VP,
<br>
Op2VP, Operands);
<br>
int VecCost = TTI->getArithmeticInstrCost(S.Opcode,
VecTy, Op1VK, Op2VK,
<br>
Op1VP, Op2VP,
Operands);
<br>
- return ReuseShuffleCost + VecCost - ScalarCost;
<br>
+ return VecCost - ScalarCost;
<br>
}
<br>
case Instruction::GetElementPtr: {
<br>
TargetTransformInfo::OperandValueKind Op1VK =
<br>
@@ -2214,46 +2151,31 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
TargetTransformInfo::OperandValueKind Op2VK =
<br>
TargetTransformInfo::OK_UniformConstantValue;
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost -= (ReuseShuffleNumbers - VL.size()) *
<br>
-
TTI->getArithmeticInstrCost(Instruction::Add,
<br>
-
ScalarTy, Op1VK, Op2VK);
<br>
- }
<br>
int ScalarCost =
<br>
VecTy->getNumElements() *
<br>
TTI->getArithmeticInstrCost(Instruction::Add,
ScalarTy, Op1VK, Op2VK);
<br>
int VecCost =
<br>
TTI->getArithmeticInstrCost(Instruction::Add,
VecTy, Op1VK, Op2VK);
<br>
- return ReuseShuffleCost + VecCost - ScalarCost;
<br>
+ return VecCost - ScalarCost;
<br>
}
<br>
case Instruction::Load: {
<br>
// Cost of wide load - cost of scalar loads.
<br>
unsigned alignment =
dyn_cast<LoadInst>(VL0)->getAlignment();
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost -= (ReuseShuffleNumbers - VL.size()) *
<br>
-
TTI->getMemoryOpCost(Instruction::Load, ScalarTy,
<br>
- alignment, 0,
VL0);
<br>
- }
<br>
int ScalarLdCost = VecTy->getNumElements() *
<br>
TTI->getMemoryOpCost(Instruction::Load, ScalarTy,
alignment, 0, VL0);
<br>
int VecLdCost =
TTI->getMemoryOpCost(Instruction::Load,
<br>
VecTy, alignment,
0, VL0);
<br>
- return ReuseShuffleCost + VecLdCost - ScalarLdCost;
<br>
+ return VecLdCost - ScalarLdCost;
<br>
}
<br>
case Instruction::Store: {
<br>
// We know that we can merge the stores. Calculate the
cost.
<br>
unsigned alignment =
dyn_cast<StoreInst>(VL0)->getAlignment();
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost -= (ReuseShuffleNumbers - VL.size()) *
<br>
-
TTI->getMemoryOpCost(Instruction::Store, ScalarTy,
<br>
- alignment, 0,
VL0);
<br>
- }
<br>
int ScalarStCost = VecTy->getNumElements() *
<br>
TTI->getMemoryOpCost(Instruction::Store,
ScalarTy, alignment, 0, VL0);
<br>
int VecStCost =
TTI->getMemoryOpCost(Instruction::Store,
<br>
VecTy, alignment,
0, VL0);
<br>
- return ReuseShuffleCost + VecStCost - ScalarStCost;
<br>
+ return VecStCost - ScalarStCost;
<br>
}
<br>
case Instruction::Call: {
<br>
CallInst *CI = cast<CallInst>(VL0);
<br>
@@ -2268,11 +2190,6 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
if (auto *FPMO = dyn_cast<FPMathOperator>(CI))
<br>
FMF = FPMO->getFastMathFlags();
<br>
- if (NeedToShuffleReuses) {
<br>
- ReuseShuffleCost -=
<br>
- (ReuseShuffleNumbers - VL.size()) *
<br>
- TTI->getIntrinsicInstrCost(ID, ScalarTy,
ScalarTys, FMF);
<br>
- }
<br>
int ScalarCallCost = VecTy->getNumElements() *
<br>
TTI->getIntrinsicInstrCost(ID, ScalarTy,
ScalarTys, FMF);
<br>
@@ -2284,7 +2201,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
<< " (" << VecCallCost << "-"
<< ScalarCallCost << ")"
<br>
<< " for " << *CI << "\n");
<br>
- return ReuseShuffleCost + VecCallCost - ScalarCallCost;
<br>
+ return VecCallCost - ScalarCallCost;
<br>
}
<br>
case Instruction::ShuffleVector: {
<br>
TargetTransformInfo::OperandValueKind Op1VK =
<br>
@@ -2292,22 +2209,6 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
TargetTransformInfo::OperandValueKind Op2VK =
<br>
TargetTransformInfo::OK_AnyValue;
<br>
int ScalarCost = 0;
<br>
- if (NeedToShuffleReuses) {
<br>
- for (unsigned Idx : E->ReuseShuffleIndices) {
<br>
- Instruction *I = cast<Instruction>(VL[Idx]);
<br>
- if (!I)
<br>
- continue;
<br>
- ReuseShuffleCost -= TTI->getArithmeticInstrCost(
<br>
- I->getOpcode(), ScalarTy, Op1VK, Op2VK);
<br>
- }
<br>
- for (Value *V : VL) {
<br>
- Instruction *I = cast<Instruction>(V);
<br>
- if (!I)
<br>
- continue;
<br>
- ReuseShuffleCost += TTI->getArithmeticInstrCost(
<br>
- I->getOpcode(), ScalarTy, Op1VK, Op2VK);
<br>
- }
<br>
- }
<br>
int VecCost = 0;
<br>
for (Value *i : VL) {
<br>
Instruction *I = cast<Instruction>(i);
<br>
@@ -2326,7 +2227,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E)
<br>
TTI->getArithmeticInstrCost(I1->getOpcode(),
VecTy, Op1VK, Op2VK);
<br>
VecCost +=
<br>
TTI->getShuffleCost(TargetTransformInfo::SK_Alternate, VecTy,
0);
<br>
- return ReuseShuffleCost + VecCost - ScalarCost;
<br>
+ return VecCost - ScalarCost;
<br>
}
<br>
default:
<br>
llvm_unreachable("Unknown instruction");
<br>
@@ -2502,14 +2403,10 @@ int BoUpSLP::getTreeCost() {
<br>
return Cost;
<br>
}
<br>
-int BoUpSLP::getGatherCost(Type *Ty,
<br>
- const DenseSet<unsigned>
&ShuffledIndices) {
<br>
+int BoUpSLP::getGatherCost(Type *Ty) {
<br>
int Cost = 0;
<br>
for (unsigned i = 0, e =
cast<VectorType>(Ty)->getNumElements(); i < e; ++i)
<br>
- if (!ShuffledIndices.count(i))
<br>
- Cost +=
TTI->getVectorInstrCost(Instruction::InsertElement, Ty, i);
<br>
- if (!ShuffledIndices.empty())
<br>
- Cost +=
TTI->getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc,
Ty);
<br>
+ Cost +=
TTI->getVectorInstrCost(Instruction::InsertElement, Ty, i);
<br>
return Cost;
<br>
}
<br>
@@ -2520,17 +2417,7 @@ int
BoUpSLP::getGatherCost(ArrayRef<Valu
<br>
ScalarTy = SI->getValueOperand()->getType();
<br>
VectorType *VecTy = VectorType::get(ScalarTy, VL.size());
<br>
// Find the cost of inserting/extracting values from the
vector.
<br>
- // Check if the same elements are inserted several times and
count them as
<br>
- // shuffle candidates.
<br>
- DenseSet<unsigned> ShuffledElements;
<br>
- DenseSet<Value *> UniqueElements;
<br>
- // Iterate in reverse order to consider insert elements with
the high cost.
<br>
- for (unsigned I = VL.size(); I > 0; --I) {
<br>
- unsigned Idx = I - 1;
<br>
- if (!UniqueElements.insert(VL[Idx]).second)
<br>
- ShuffledElements.insert(Idx);
<br>
- }
<br>
- return getGatherCost(VecTy, ShuffledElements);
<br>
+ return getGatherCost(VecTy);
<br>
}
<br>
// Reorder commutative operations in alternate shuffle if
the resulting vectors
<br>
@@ -2828,7 +2715,7 @@ Value *BoUpSLP::Gather(ArrayRef<Value
*>
<br>
if (TreeEntry *E = getTreeEntry(VL[i])) {
<br>
// Find which lane we need to extract.
<br>
int FoundLane = -1;
<br>
- for (unsigned Lane = 0, LE = E->Scalars.size(); Lane
!= LE; ++Lane) {
<br>
+ for (unsigned Lane = 0, LE = VL.size(); Lane != LE;
++Lane) {
<br>
// Is this the lane of the scalar that we are
looking for ?
<br>
if (E->Scalars[Lane] == VL[i]) {
<br>
FoundLane = Lane;
<br>
@@ -2844,6 +2731,14 @@ Value *BoUpSLP::Gather(ArrayRef<Value
*>
<br>
return Vec;
<br>
}
<br>
+Value *BoUpSLP::alreadyVectorized(ArrayRef<Value *> VL,
Value *OpValue) const {
<br>
+ if (const TreeEntry *En = getTreeEntry(OpValue)) {
<br>
+ if (En->isSame(VL) && En->VectorizedValue)
<br>
+ return En->VectorizedValue;
<br>
+ }
<br>
+ return nullptr;
<br>
+}
<br>
+
<br>
Value *BoUpSLP::vectorizeTree(ArrayRef<Value *> VL) {
<br>
InstructionsState S = getSameOpcode(VL);
<br>
if (S.Opcode) {
<br>
@@ -2856,38 +2751,9 @@ Value
*BoUpSLP::vectorizeTree(ArrayRef<V
<br>
Type *ScalarTy = S.OpValue->getType();
<br>
if (StoreInst *SI = dyn_cast<StoreInst>(S.OpValue))
<br>
ScalarTy = SI->getValueOperand()->getType();
<br>
-
<br>
- // Check that every instruction appears once in this bundle.
<br>
- SmallVector<unsigned, 4> ReuseShuffleIndicies;
<br>
- SmallVector<Value *, 4> UniqueValues;
<br>
- if (VL.size() > 2) {
<br>
- DenseMap<Value *, unsigned> UniquePositions;
<br>
- for (Value *V : VL) {
<br>
- auto Res = UniquePositions.try_emplace(V,
UniqueValues.size());
<br>
- ReuseShuffleIndicies.emplace_back(Res.first->second);
<br>
- if (Res.second || isa<Constant>(V))
<br>
- UniqueValues.emplace_back(V);
<br>
- }
<br>
- // Do not shuffle single element or if number of unique
values is not power
<br>
- // of 2.
<br>
- if (UniqueValues.size() == VL.size() || UniqueValues.size()
<= 1 ||
<br>
- !llvm::isPowerOf2_32(UniqueValues.size()))
<br>
- ReuseShuffleIndicies.clear();
<br>
- else
<br>
- VL = UniqueValues;
<br>
- }
<br>
VectorType *VecTy = VectorType::get(ScalarTy, VL.size());
<br>
- Value *V = Gather(VL, VecTy);
<br>
- if (!ReuseShuffleIndicies.empty()) {
<br>
- V = Builder.CreateShuffleVector(V, UndefValue::get(VecTy),
<br>
- ReuseShuffleIndicies,
"shuffle");
<br>
- if (auto *I = dyn_cast<Instruction>(V)) {
<br>
- GatherSeq.insert(I);
<br>
- CSEBlocks.insert(I->getParent());
<br>
- }
<br>
- }
<br>
- return V;
<br>
+ return Gather(VL, VecTy);
<br>
}
<br>
Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
<br>
@@ -2905,19 +2771,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
ScalarTy = SI->getValueOperand()->getType();
<br>
VectorType *VecTy = VectorType::get(ScalarTy,
E->Scalars.size());
<br>
- bool NeedToShuffleReuses =
!E->ReuseShuffleIndices.empty();
<br>
-
<br>
if (E->NeedToGather) {
<br>
setInsertPointAfterBundle(E->Scalars, VL0);
<br>
auto *V = Gather(E->Scalars, VecTy);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- if (auto *I = dyn_cast<Instruction>(V)) {
<br>
- GatherSeq.insert(I);
<br>
- CSEBlocks.insert(I->getParent());
<br>
- }
<br>
- }
<br>
E->VectorizedValue = V;
<br>
return V;
<br>
}
<br>
@@ -2930,12 +2786,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Builder.SetInsertPoint(PH->getParent()->getFirstNonPHI());
<br>
Builder.SetCurrentDebugLocation(PH->getDebugLoc());
<br>
PHINode *NewPhi = Builder.CreatePHI(VecTy,
PH->getNumIncomingValues());
<br>
- Value *V = NewPhi;
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
- E->VectorizedValue = V;
<br>
+ E->VectorizedValue = NewPhi;
<br>
// PHINodes may have multiple entries from the same
block. We want to
<br>
// visit every block once.
<br>
@@ -2962,30 +2813,17 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
assert(NewPhi->getNumIncomingValues() ==
PH->getNumIncomingValues() &&
<br>
"Invalid number of incoming values");
<br>
- return V;
<br>
+ return NewPhi;
<br>
}
<br>
case Instruction::ExtractElement: {
<br>
if (canReuseExtract(E->Scalars, VL0)) {
<br>
Value *V = VL0->getOperand(0);
<br>
- if (NeedToShuffleReuses) {
<br>
- Builder.SetInsertPoint(VL0);
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
return V;
<br>
}
<br>
setInsertPointAfterBundle(E->Scalars, VL0);
<br>
auto *V = Gather(E->Scalars, VecTy);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- if (auto *I = dyn_cast<Instruction>(V)) {
<br>
- GatherSeq.insert(I);
<br>
- CSEBlocks.insert(I->getParent());
<br>
- }
<br>
- }
<br>
E->VectorizedValue = V;
<br>
return V;
<br>
}
<br>
@@ -2996,24 +2834,11 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
PointerType *PtrTy = PointerType::get(VecTy,
LI->getPointerAddressSpace());
<br>
Value *Ptr =
Builder.CreateBitCast(LI->getOperand(0), PtrTy);
<br>
LoadInst *V = Builder.CreateAlignedLoad(Ptr,
LI->getAlignment());
<br>
- Value *NewV = propagateMetadata(V, E->Scalars);
<br>
- if (NeedToShuffleReuses) {
<br>
- NewV = Builder.CreateShuffleVector(
<br>
- NewV, UndefValue::get(VecTy),
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
- E->VectorizedValue = NewV;
<br>
- return NewV;
<br>
+ E->VectorizedValue = V;
<br>
+ return propagateMetadata(V, E->Scalars);
<br>
}
<br>
setInsertPointAfterBundle(E->Scalars, VL0);
<br>
auto *V = Gather(E->Scalars, VecTy);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- if (auto *I = dyn_cast<Instruction>(V)) {
<br>
- GatherSeq.insert(I);
<br>
- CSEBlocks.insert(I->getParent());
<br>
- }
<br>
- }
<br>
E->VectorizedValue = V;
<br>
return V;
<br>
}
<br>
@@ -3037,17 +2862,11 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Value *InVec = vectorizeTree(INVL);
<br>
- if (E->VectorizedValue) {
<br>
- DEBUG(dbgs() << "SLP: Diamond merged for "
<< *VL0 << ".\n");
<br>
- return E->VectorizedValue;
<br>
- }
<br>
+ if (Value *V = alreadyVectorized(E->Scalars, VL0))
<br>
+ return V;
<br>
CastInst *CI = dyn_cast<CastInst>(VL0);
<br>
Value *V = Builder.CreateCast(CI->getOpcode(), InVec,
VecTy);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
++NumVectorInstructions;
<br>
return V;
<br>
@@ -3065,10 +2884,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Value *L = vectorizeTree(LHSV);
<br>
Value *R = vectorizeTree(RHSV);
<br>
- if (E->VectorizedValue) {
<br>
- DEBUG(dbgs() << "SLP: Diamond merged for "
<< *VL0 << ".\n");
<br>
- return E->VectorizedValue;
<br>
- }
<br>
+ if (Value *V = alreadyVectorized(E->Scalars, VL0))
<br>
+ return V;
<br>
CmpInst::Predicate P0 =
cast<CmpInst>(VL0)->getPredicate();
<br>
Value *V;
<br>
@@ -3077,12 +2894,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
else
<br>
V = Builder.CreateICmp(P0, L, R);
<br>
- propagateIRFlags(V, E->Scalars, VL0);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
+ propagateIRFlags(E->VectorizedValue, E->Scalars,
VL0);
<br>
++NumVectorInstructions;
<br>
return V;
<br>
}
<br>
@@ -3100,16 +2913,10 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Value *True = vectorizeTree(TrueVec);
<br>
Value *False = vectorizeTree(FalseVec);
<br>
- if (E->VectorizedValue) {
<br>
- DEBUG(dbgs() << "SLP: Diamond merged for "
<< *VL0 << ".\n");
<br>
- return E->VectorizedValue;
<br>
- }
<br>
+ if (Value *V = alreadyVectorized(E->Scalars, VL0))
<br>
+ return V;
<br>
Value *V = Builder.CreateSelect(Cond, True, False);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
++NumVectorInstructions;
<br>
return V;
<br>
@@ -3148,24 +2955,18 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Value *LHS = vectorizeTree(LHSVL);
<br>
Value *RHS = vectorizeTree(RHSVL);
<br>
- if (E->VectorizedValue) {
<br>
- DEBUG(dbgs() << "SLP: Diamond merged for "
<< *VL0 << ".\n");
<br>
- return E->VectorizedValue;
<br>
- }
<br>
+ if (Value *V = alreadyVectorized(E->Scalars, VL0))
<br>
+ return V;
<br>
Value *V = Builder.CreateBinOp(
<br>
static_cast<Instruction::BinaryOps>(S.Opcode),
LHS, RHS);
<br>
- propagateIRFlags(V, E->Scalars, VL0);
<br>
- if (auto *I = dyn_cast<Instruction>(V))
<br>
- V = propagateMetadata(I, E->Scalars);
<br>
-
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
+ propagateIRFlags(E->VectorizedValue, E->Scalars,
VL0);
<br>
++NumVectorInstructions;
<br>
+ if (Instruction *I = dyn_cast<Instruction>(V))
<br>
+ return propagateMetadata(I, E->Scalars);
<br>
+
<br>
return V;
<br>
}
<br>
case Instruction::Load: {
<br>
@@ -3193,14 +2994,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Alignment = DL->getABITypeAlignment(ScalarLoadTy);
<br>
}
<br>
LI->setAlignment(Alignment);
<br>
- Value *V = propagateMetadata(LI, E->Scalars);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
- E->VectorizedValue = V;
<br>
+ E->VectorizedValue = LI;
<br>
++NumVectorInstructions;
<br>
- return V;
<br>
+ return propagateMetadata(LI, E->Scalars);
<br>
}
<br>
case Instruction::Store: {
<br>
StoreInst *SI = cast<StoreInst>(VL0);
<br>
@@ -3228,14 +3024,9 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Alignment =
DL->getABITypeAlignment(SI->getValueOperand()->getType());
<br>
S->setAlignment(Alignment);
<br>
- Value *V = propagateMetadata(S, E->Scalars);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
- E->VectorizedValue = V;
<br>
+ E->VectorizedValue = S;
<br>
++NumVectorInstructions;
<br>
- return V;
<br>
+ return propagateMetadata(S, E->Scalars);
<br>
}
<br>
case Instruction::GetElementPtr: {
<br>
setInsertPointAfterBundle(E->Scalars, VL0);
<br>
@@ -3259,16 +3050,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Value *V = Builder.CreateGEP(
<br>
cast<GetElementPtrInst>(VL0)->getSourceElementType(),
Op0, OpVecs);
<br>
- if (Instruction *I = dyn_cast<Instruction>(V))
<br>
- V = propagateMetadata(I, E->Scalars);
<br>
-
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
++NumVectorInstructions;
<br>
+ if (Instruction *I = dyn_cast<Instruction>(V))
<br>
+ return propagateMetadata(I, E->Scalars);
<br>
+
<br>
return V;
<br>
}
<br>
case Instruction::Call: {
<br>
@@ -3315,12 +3102,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
if (ScalarArg && getTreeEntry(ScalarArg))
<br>
ExternalUses.push_back(ExternalUser(ScalarArg,
cast<User>(V), 0));
<br>
- propagateIRFlags(V, E->Scalars, VL0);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
+ propagateIRFlags(E->VectorizedValue, E->Scalars,
VL0);
<br>
++NumVectorInstructions;
<br>
return V;
<br>
}
<br>
@@ -3334,10 +3117,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
Value *LHS = vectorizeTree(LHSVL);
<br>
Value *RHS = vectorizeTree(RHSVL);
<br>
- if (E->VectorizedValue) {
<br>
- DEBUG(dbgs() << "SLP: Diamond merged for "
<< *VL0 << ".\n");
<br>
- return E->VectorizedValue;
<br>
- }
<br>
+ if (Value *V = alreadyVectorized(E->Scalars, VL0))
<br>
+ return V;
<br>
// Create a vector of LHS op1 RHS
<br>
Value *V0 = Builder.CreateBinOp(
<br>
@@ -3369,14 +3150,10 @@ Value *BoUpSLP::vectorizeTree(TreeEntry
<br>
propagateIRFlags(V1, OddScalars);
<br>
Value *V = Builder.CreateShuffleVector(V0, V1,
ShuffleMask);
<br>
- if (Instruction *I = dyn_cast<Instruction>(V))
<br>
- V = propagateMetadata(I, E->Scalars);
<br>
- if (NeedToShuffleReuses) {
<br>
- V = Builder.CreateShuffleVector(V,
UndefValue::get(VecTy),
<br>
-
E->ReuseShuffleIndices, "shuffle");
<br>
- }
<br>
E->VectorizedValue = V;
<br>
++NumVectorInstructions;
<br>
+ if (Instruction *I = dyn_cast<Instruction>(V))
<br>
+ return propagateMetadata(I, E->Scalars);
<br>
return V;
<br>
}
<br>
@@ -3546,12 +3323,14 @@ void BoUpSLP::optimizeGatherSequence() {
<br>
DEBUG(dbgs() << "SLP: Optimizing " <<
GatherSeq.size()
<br>
<< " gather sequences instructions.\n");
<br>
// LICM InsertElementInst sequences.
<br>
- for (Instruction *I : GatherSeq) {
<br>
- if (!isa<InsertElementInst>(I) &&
!isa<ShuffleVectorInst>(I))
<br>
+ for (Instruction *it : GatherSeq) {
<br>
+ InsertElementInst *Insert =
dyn_cast<InsertElementInst>(it);
<br>
+
<br>
+ if (!Insert)
<br>
continue;
<br>
// Check if this block is inside a loop.
<br>
- Loop *L = LI->getLoopFor(I->getParent());
<br>
+ Loop *L = LI->getLoopFor(Insert->getParent());
<br>
if (!L)
<br>
continue;
<br>
@@ -3563,15 +3342,15 @@ void BoUpSLP::optimizeGatherSequence()
{
<br>
// If the vector or the element that we insert into it are
<br>
// instructions that are defined in this basic block then
we can't
<br>
// hoist this instruction.
<br>
- auto *Op0 =
dyn_cast<Instruction>(I->getOperand(0));
<br>
- auto *Op1 =
dyn_cast<Instruction>(I->getOperand(1));
<br>
- if (Op0 && L->contains(Op0))
<br>
+ Instruction *CurrVec =
dyn_cast<Instruction>(Insert->getOperand(0));
<br>
+ Instruction *NewElem =
dyn_cast<Instruction>(Insert->getOperand(1));
<br>
+ if (CurrVec && L->contains(CurrVec))
<br>
continue;
<br>
- if (Op1 && L->contains(Op1))
<br>
+ if (NewElem && L->contains(NewElem))
<br>
continue;
<br>
// We can hoist this instruction. Move it to the
pre-header.
<br>
- I->moveBefore(PreHeader->getTerminator());
<br>
+ Insert->moveBefore(PreHeader->getTerminator());
<br>
}
<br>
// Make a list of all reachable blocks in our CSE queue.
<br>
<br>
Modified:
llvm/trunk/test/Transforms/SLPVectorizer/X86/PR32086.ll
<br>
URL:
<a class="moz-txt-link-freetext" href="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Ftest%2FTransforms%2FSLPVectorizer%2FX86%2FPR32086.ll%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=NKpicN1iP9oEBrVAJEITogQ%2Bcn7UrX9pdzVHFmrLi3s%3D&reserved=0">https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Ftest%2FTransforms%2FSLPVectorizer%2FX86%2FPR32086.ll%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=NKpicN1iP9oEBrVAJEITogQ%2Bcn7UrX9pdzVHFmrLi3s%3D&reserved=0</a><br>
==============================================================================
<br>
--- llvm/trunk/test/Transforms/SLPVectorizer/X86/PR32086.ll
(original)
<br>
+++ llvm/trunk/test/Transforms/SLPVectorizer/X86/PR32086.ll Thu
Jan 25 09:28:12 2018
<br>
@@ -4,14 +4,15 @@
<br>
define void @i64_simplified(i64* noalias %st, i64* noalias
%ld) {
<br>
; CHECK-LABEL: @i64_simplified(
<br>
; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds
i64, i64* [[LD:%.*]], i64 1
<br>
-; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64* [[LD]] to <2 x
i64>*
<br>
-; CHECK-NEXT: [[TMP2:%.*]] = load <2 x i64>, <2 x
i64>* [[TMP1]], align 8
<br>
-; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <2 x
i64> [[TMP2]], <2 x i64> undef, <4 x i32> <i32
0, i32 1, i32 0, i32 1>
<br>
+; CHECK-NEXT: [[T0:%.*]] = load i64, i64* [[LD]], align 8
<br>
+; CHECK-NEXT: [[T1:%.*]] = load i64, i64* [[ARRAYIDX1]],
align 8
<br>
; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds
i64, i64* [[ST:%.*]], i64 1
<br>
; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds
i64, i64* [[ST]], i64 2
<br>
; CHECK-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds
i64, i64* [[ST]], i64 3
<br>
-; CHECK-NEXT: [[TMP3:%.*]] = bitcast i64* [[ST]] to <4 x
i64>*
<br>
-; CHECK-NEXT: store <4 x i64> [[SHUFFLE]], <4 x
i64>* [[TMP3]], align 8
<br>
+; CHECK-NEXT: store i64 [[T0]], i64* [[ST]], align 8
<br>
+; CHECK-NEXT: store i64 [[T1]], i64* [[ARRAYIDX3]], align 8
<br>
+; CHECK-NEXT: store i64 [[T0]], i64* [[ARRAYIDX4]], align 8
<br>
+; CHECK-NEXT: store i64 [[T1]], i64* [[ARRAYIDX5]], align 8
<br>
; CHECK-NEXT: ret void
<br>
;
<br>
%arrayidx1 = getelementptr inbounds i64, i64* %ld, i64 1
<br>
<br>
Modified:
llvm/trunk/test/Transforms/SLPVectorizer/X86/blending-shuffle.ll
<br>
URL:
<a class="moz-txt-link-freetext" href="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Ftest%2FTransforms%2FSLPVectorizer%2FX86%2Fblending-shuffle.ll%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=xYjEZJR7IqLGGgau83o%2BfPRrQUi2OKE%2FurY%2Br6ViHZE%3D&reserved=0">https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Ftest%2FTransforms%2FSLPVectorizer%2FX86%2Fblending-shuffle.ll%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=xYjEZJR7IqLGGgau83o%2BfPRrQUi2OKE%2FurY%2Br6ViHZE%3D&reserved=0</a><br>
==============================================================================
<br>
---
llvm/trunk/test/Transforms/SLPVectorizer/X86/blending-shuffle.ll
(original)
<br>
+++
llvm/trunk/test/Transforms/SLPVectorizer/X86/blending-shuffle.ll
Thu Jan 25 09:28:12 2018
<br>
@@ -137,19 +137,17 @@ define i8 @k(<4 x i8> %x) {
<br>
define i8 @k_bb(<4 x i8> %x) {
<br>
; CHECK-LABEL: @k_bb(
<br>
-; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i8>
[[X:%.*]], i32 0
<br>
; CHECK-NEXT: br label [[BB1:%.*]]
<br>
; CHECK: bb1:
<br>
-; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i8>
[[X]], i32 3
<br>
-; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
<br>
-; CHECK-NEXT: [[X3X3:%.*]] = mul i8 [[X3]], [[X3]]
<br>
-; CHECK-NEXT: [[TMP1:%.*]] = mul <4 x i8> [[X]], [[X]]
<br>
-; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[X0X0]], [[X3X3]]
<br>
-; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i8>
[[TMP1]], i32 1
<br>
-; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x i8>
[[TMP1]], i32 2
<br>
-; CHECK-NEXT: [[TMP5:%.*]] = add i8 [[TMP3]], [[TMP4]]
<br>
-; CHECK-NEXT: [[TMP6:%.*]] = sdiv i8 [[TMP2]], [[TMP5]]
<br>
-; CHECK-NEXT: ret i8 [[TMP6]]
<br>
+; CHECK-NEXT: [[TMP1:%.*]] = mul <4 x i8> [[X:%.*]],
[[X]]
<br>
+; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i8>
[[TMP1]], <4 x i8> undef, <2 x i32> <i32 0, i32
1>
<br>
+; CHECK-NEXT: [[TMP3:%.*]] = mul <4 x i8> [[X]], [[X]]
<br>
+; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <4 x i8>
[[TMP3]], <4 x i8> undef, <2 x i32> <i32 3, i32
2>
<br>
+; CHECK-NEXT: [[TMP5:%.*]] = add <2 x i8> [[TMP2]],
[[TMP4]]
<br>
+; CHECK-NEXT: [[TMP6:%.*]] = extractelement <2 x i8>
[[TMP5]], i32 0
<br>
+; CHECK-NEXT: [[TMP7:%.*]] = extractelement <2 x i8>
[[TMP5]], i32 1
<br>
+; CHECK-NEXT: [[TMP8:%.*]] = sdiv i8 [[TMP6]], [[TMP7]]
<br>
+; CHECK-NEXT: ret i8 [[TMP8]]
<br>
;
<br>
%x0 = extractelement <4 x i8> %x, i32 0
<br>
br label %bb1
<br>
<br>
Modified: llvm/trunk/test/Transforms/SLPVectorizer/X86/hoist.ll
<br>
URL:
<a class="moz-txt-link-freetext" href="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Ftest%2FTransforms%2FSLPVectorizer%2FX86%2Fhoist.ll%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=QTK%2BopMfyMoe7w8tPevAALIb1QjdWXufsTTiPeft%2FXo%3D&reserved=0">https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fllvm%2Ftrunk%2Ftest%2FTransforms%2FSLPVectorizer%2FX86%2Fhoist.ll%3Frev%3D323447%26r1%3D323446%26r2%3D323447%26view%3Ddiff&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=QTK%2BopMfyMoe7w8tPevAALIb1QjdWXufsTTiPeft%2FXo%3D&reserved=0</a><br>
==============================================================================
<br>
--- llvm/trunk/test/Transforms/SLPVectorizer/X86/hoist.ll
(original)
<br>
+++ llvm/trunk/test/Transforms/SLPVectorizer/X86/hoist.ll Thu
Jan 25 09:28:12 2018
<br>
@@ -16,18 +16,19 @@ target triple = "i386-apple-macosx10.9.0
<br>
define i32 @foo(i32* nocapture %A, i32 %n, i32 %k) {
<br>
; CHECK-LABEL: @foo(
<br>
; CHECK-NEXT: entry:
<br>
-; CHECK-NEXT: [[TMP0:%.*]] = insertelement <2 x i32>
undef, i32 [[N:%.*]], i32 0
<br>
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i32>
[[TMP0]], i32 [[K:%.*]], i32 1
<br>
-; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <2 x
i32> [[TMP1]], <2 x i32> undef, <4 x i32> <i32
0, i32 1, i32 0, i32 1>
<br>
+; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i32>
undef, i32 [[N:%.*]], i32 0
<br>
+; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32>
[[TMP0]], i32 [[K:%.*]], i32 1
<br>
+; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i32>
[[TMP1]], i32 [[N]], i32 2
<br>
+; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i32>
[[TMP2]], i32 [[K]], i32 3
<br>
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
<br>
; CHECK: for.body:
<br>
; CHECK-NEXT: [[I_024:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ],
[ [[ADD10:%.*]], [[FOR_BODY]] ]
<br>
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds
i32, i32* [[A:%.*]], i32 [[I_024]]
<br>
-; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[ARRAYIDX]] to
<4 x i32>*
<br>
-; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, <4 x
i32>* [[TMP2]], align 4
<br>
-; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32>
[[SHUFFLE]], [[TMP3]]
<br>
-; CHECK-NEXT: [[TMP5:%.*]] = bitcast i32* [[ARRAYIDX]] to
<4 x i32>*
<br>
-; CHECK-NEXT: store <4 x i32> [[TMP4]], <4 x
i32>* [[TMP5]], align 4
<br>
+; CHECK-NEXT: [[TMP4:%.*]] = bitcast i32* [[ARRAYIDX]] to
<4 x i32>*
<br>
+; CHECK-NEXT: [[TMP5:%.*]] = load <4 x i32>, <4 x
i32>* [[TMP4]], align 4
<br>
+; CHECK-NEXT: [[TMP6:%.*]] = add nsw <4 x i32>
[[TMP3]], [[TMP5]]
<br>
+; CHECK-NEXT: [[TMP7:%.*]] = bitcast i32* [[ARRAYIDX]] to
<4 x i32>*
<br>
+; CHECK-NEXT: store <4 x i32> [[TMP6]], <4 x
i32>* [[TMP7]], align 4
<br>
; CHECK-NEXT: [[ADD10]] = add nsw i32 [[I_024]], 4
<br>
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[ADD10]], 10000
<br>
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label
[[FOR_END:%.*]]
<br>
<br>
<br>
_______________________________________________
<br>
llvm-commits mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-commits&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=%2BXn23%2BRRuM6xvAsZ4dF0PW%2FOaJGl4vxTju8FUK2DUPA%3D&reserved=0">https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-commits&data=02%7C01%7C%7Ca0ca24dbbe9544e0eaaa08d5673f6a31%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636528444413469003&sdata=%2BXn23%2BRRuM6xvAsZ4dF0PW%2FOaJGl4vxTju8FUK2DUPA%3D&reserved=0</a>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>