Skip to content

Commit 6e1eaac

Browse files
author
Chad Rosier
committedAug 29, 2016
[SLP] Return a boolean value for these static helpers. NFC.
Differential Revision: https://reviews.llvm.org/D24008 llvm-svn: 280020
1 parent 77ed6af commit 6e1eaac

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed
 

‎llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

+16-17
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,22 @@ static bool isValidElementType(Type *Ty) {
115115
!Ty->isPPC_FP128Ty();
116116
}
117117

118-
/// \returns the parent basic block if all of the instructions in \p VL
119-
/// are in the same block or null otherwise.
120-
static BasicBlock *getSameBlock(ArrayRef<Value *> VL) {
118+
/// \returns true if all of the instructions in \p VL are in the same block or
119+
/// false otherwise.
120+
static bool allSameBlock(ArrayRef<Value *> VL) {
121121
Instruction *I0 = dyn_cast<Instruction>(VL[0]);
122122
if (!I0)
123-
return nullptr;
123+
return false;
124124
BasicBlock *BB = I0->getParent();
125125
for (int i = 1, e = VL.size(); i < e; i++) {
126126
Instruction *I = dyn_cast<Instruction>(VL[i]);
127127
if (!I)
128-
return nullptr;
128+
return false;
129129

130130
if (BB != I->getParent())
131-
return nullptr;
131+
return false;
132132
}
133-
return BB;
133+
return true;
134134
}
135135

136136
/// \returns True if all of the values in \p VL are constants.
@@ -224,15 +224,15 @@ static void propagateIRFlags(Value *I, ArrayRef<Value *> VL) {
224224
}
225225
}
226226

227-
/// \returns The type that all of the values in \p VL have or null if there
228-
/// are different types.
229-
static Type* getSameType(ArrayRef<Value *> VL) {
227+
/// \returns true if all of the values in \p VL have the same type or false
228+
/// otherwise.
229+
static bool allSameType(ArrayRef<Value *> VL) {
230230
Type *Ty = VL[0]->getType();
231231
for (int i = 1, e = VL.size(); i < e; i++)
232232
if (VL[i]->getType() != Ty)
233-
return nullptr;
233+
return false;
234234

235-
return Ty;
235+
return true;
236236
}
237237

238238
/// \returns True if Extract{Value,Element} instruction extracts element Idx.
@@ -921,7 +921,7 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
921921
ArrayRef<Value *> UserIgnoreLst) {
922922
deleteTree();
923923
UserIgnoreList = UserIgnoreLst;
924-
if (!getSameType(Roots))
924+
if (!allSameType(Roots))
925925
return;
926926
buildTree_rec(Roots, 0);
927927

@@ -975,9 +975,8 @@ void BoUpSLP::buildTree(ArrayRef<Value *> Roots,
975975

976976

977977
void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth) {
978-
bool SameTy = allConstant(VL) || getSameType(VL); (void)SameTy;
979978
bool isAltShuffle = false;
980-
assert(SameTy && "Invalid types!");
979+
assert((allConstant(VL) || allSameType(VL)) && "Invalid types!");
981980

982981
if (Depth == RecursionMaxDepth) {
983982
DEBUG(dbgs() << "SLP: Gathering due to max recursion depth.\n");
@@ -1010,7 +1009,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth) {
10101009
}
10111010

10121011
// If all of the operands are identical or constant we have a simple solution.
1013-
if (allConstant(VL) || isSplat(VL) || !getSameBlock(VL) || !Opcode) {
1012+
if (allConstant(VL) || isSplat(VL) || !allSameBlock(VL) || !Opcode) {
10141013
DEBUG(dbgs() << "SLP: Gathering due to C,S,B,O. \n");
10151014
newTreeEntry(VL, false);
10161015
return;
@@ -1585,7 +1584,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
15851584
return getGatherCost(E->Scalars);
15861585
}
15871586
unsigned Opcode = getSameOpcode(VL);
1588-
assert(Opcode && getSameType(VL) && getSameBlock(VL) && "Invalid VL");
1587+
assert(Opcode && allSameType(VL) && allSameBlock(VL) && "Invalid VL");
15891588
Instruction *VL0 = cast<Instruction>(VL[0]);
15901589
switch (Opcode) {
15911590
case Instruction::PHI: {

0 commit comments

Comments
 (0)
Please sign in to comment.