[PATCH] Refactor: Simplify boolean conditional return statements in lib/Transforms/Vectorize
Michael Zolotukhin
mzolotukhin at apple.com
Mon May 25 12:47:32 PDT 2015
Hi Richard,
Thanks for cleaning this up. In the first spot I prefer the original version, but the rest look fine (and if you feel strong about the first place too, I don't mind committing the change there as well).
Please mention that it's NFC in the commit message.
Thanks,
Michael
================
Comment at: lib/Transforms/Vectorize/BBVectorize.cpp:937-938
@@ -936,7 +936,4 @@
- if (!TTI && (T1->getPrimitiveSizeInBits() >= Config.VectorBits ||
- T2->getPrimitiveSizeInBits() >= Config.VectorBits))
- return false;
-
- return true;
+ return TTI || (T1->getPrimitiveSizeInBits() < Config.VectorBits &&
+ T2->getPrimitiveSizeInBits() < Config.VectorBits);
}
----------------
Here I prefer the original version, for me it seems more natural to express the logic.
================
Comment at: lib/Transforms/Vectorize/LoopVectorize.cpp:4461-4462
@@ -4460,5 +4460,4 @@
static bool isStrideMul(Instruction *I, LoopVectorizationLegality *Legal) {
- if (Legal->hasStride(I->getOperand(0)) || Legal->hasStride(I->getOperand(1)))
- return true;
- return false;
+ return Legal->hasStride(I->getOperand(0)) ||
+ Legal->hasStride(I->getOperand(1));
}
----------------
LGTM.
================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:154-155
@@ -153,6 +153,4 @@
static bool canCombineAsAltInst(unsigned Op) {
- if (Op == Instruction::FAdd || Op == Instruction::FSub ||
- Op == Instruction::Sub || Op == Instruction::Add)
- return true;
- return false;
+ return Op == Instruction::FAdd || Op == Instruction::FSub ||
+ Op == Instruction::Sub || Op == Instruction::Add;
}
----------------
LGTM.
================
Comment at: lib/Transforms/Vectorize/SLPVectorizer.cpp:1643
@@ -1644,6 +1642,3 @@
// Gathering cost would be too much for tiny trees.
- if (VectorizableTree[0].NeedToGather || VectorizableTree[1].NeedToGather)
- return false;
-
- return true;
+ return !VectorizableTree[0].NeedToGather && !VectorizableTree[1].NeedToGather;
}
----------------
LGTM.
http://reviews.llvm.org/D10003
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list