[NFC] Pre- increment and decrement where possible

This commit is contained in:
Anthony Latsis
2020-06-01 15:39:29 +03:00
parent ad0a8d3121
commit 9fd1aa5d59
162 changed files with 398 additions and 397 deletions

View File

@@ -446,7 +446,7 @@ static void unrollForEach(ArrayInfo &arrayInfo, TryApplyInst *forEachCall,
// than needed as the unrolled code have many branches (due to try applies)
// all of which joins later into a single path eventually.
SmallVector<SILValue, 4> elementCopies;
for (uint64_t i = 0; i < arrayInfo.getNumElements(); i++) {
for (uint64_t i = 0; i < arrayInfo.getNumElements(); ++i) {
StoreInst *elementStore = arrayInfo.getElementStore(i);
// Insert the copy just before the store of the element into the array.
SILValue copy = SILBuilderWithScope(elementStore)
@@ -516,7 +516,7 @@ static void unrollForEach(ArrayInfo &arrayInfo, TryApplyInst *forEachCall,
// it is `normalBB`. (The normal target is captured by `nextNormalBB`.)
// Jump to a new error block: err_i in the error case. Note that all
// error blocks jump to the error target of the original forEach call.
for (uint64_t num = arrayInfo.getNumElements(); num > 0; num--) {
for (uint64_t num = arrayInfo.getNumElements(); num > 0; --num) {
SILValue elementCopy = elementCopies[num - 1];
SILBasicBlock *currentBB = num > 1 ? normalTargetGenerator(nextNormalBB)
: forEachCall->getParentBlock();
@@ -604,14 +604,14 @@ class ForEachLoopUnroller : public SILFunctionTransform {
SILInstruction *inst = &*instIter;
ApplyInst *apply = dyn_cast<ApplyInst>(inst);
if (!apply) {
instIter++;
++instIter;
continue;
}
// Note that the following operation may delete a forEach call but
// would not delete this apply instruction, which is an array
// initializer. Therefore, the iterator should be valid here.
changed |= tryUnrollForEachCallsOverArrayLiteral(apply, deleter);
instIter++;
++instIter;
}
}