Skip to content

Commit 9d038e5

Browse files
mustarttMeinersbur
andauthored
address review comments
Co-authored-by: Michael Kruse <[email protected]>
1 parent 2619e67 commit 9d038e5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ using namespace llvm;
9797
STATISTIC(NumMemSet, "Number of memset's formed from loop stores");
9898
STATISTIC(NumMemCpy, "Number of memcpy's formed from loop load+stores");
9999
STATISTIC(NumMemMove, "Number of memmove's formed from loop load+stores");
100-
STATISTIC(NumStrLen, "Number of strlen's formed from loop loads");
100+
STATISTIC(NumStrLen, "Number of strlen's and wcslen's formed from loop loads");
101101
STATISTIC(
102102
NumShiftUntilBitTest,
103103
"Number of uncountable loops recognized as 'shift until bitttest' idiom");
@@ -1664,9 +1664,9 @@ class StrlenVerifier {
16641664
if (!AddRecEv || !AddRecEv->isAffine())
16651665
return false;
16661666

1667-
// We only want RecAddExpr with recurrence step that are constant. This
1668-
// is good enough for all the idioms we want to recognize. Later we expand
1669-
// the recurrence as {base,+,a} -> (base + a * strlen) and materialize
1667+
// We only want RecAddExpr with recurrence step that is constant. This
1668+
// is good enough for all the idioms we want to recognize. Later we expand and materialize
1669+
// the recurrence as {base,+,a} -> (base + a * strlen)
16701670
if (!dyn_cast<SCEVConstant>(AddRecEv->getStepRecurrence(*SE)))
16711671
return false;
16721672
}
@@ -1719,7 +1719,7 @@ class StrlenVerifier {
17191719
/// size_t result = str - base;
17201720
/// \endcode
17211721
///
1722-
/// will be transformed as as follow: The idiom will be replaced by a strlen
1722+
/// will be transformed as follows: The idiom will be replaced by a strlen
17231723
/// computation to compute the address of the null terminator of the string.
17241724
///
17251725
/// \code{.c}
@@ -1759,7 +1759,7 @@ bool LoopIdiomRecognize::recognizeAndInsertStrLen() {
17591759
BasicBlock *LoopExitBB = CurLoop->getExitBlock();
17601760

17611761
IRBuilder<> Builder(Preheader->getTerminator());
1762-
SCEVExpander Expander(*SE, Preheader->getModule()->getDataLayout(), "scev");
1762+
SCEVExpander Expander(*SE, Preheader->getModule()->getDataLayout(), "strlen_idiom");
17631763
Value *MaterialzedBase = Expander.expandCodeFor(
17641764
Verifier.LoadBaseEv, Verifier.LoadBaseEv->getType(),
17651765
Builder.GetInsertPoint());
@@ -1805,9 +1805,8 @@ bool LoopIdiomRecognize::recognizeAndInsertStrLen() {
18051805

18061806
// All LCSSA Loop Phi are dead, the left over dead loop body can be cleaned
18071807
// up by later passes
1808-
for (PHINode *PN : Cleanup) {
1808+
for (PHINode *PN : Cleanup)
18091809
RecursivelyDeleteDeadPHINode(PN);
1810-
}
18111810
SE->forgetLoop(CurLoop);
18121811

18131812
++NumStrLen;

0 commit comments

Comments
 (0)