Skip to content

Commit dee2518

Browse files
mustarttMeinersbur
andcommitted
address review comments
Co-authored-by: Michael Kruse <[email protected]>
1 parent 4e8851b commit dee2518

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");
@@ -1669,9 +1669,9 @@ class StrlenVerifier {
16691669
if (!AddRecEv || !AddRecEv->isAffine())
16701670
return false;
16711671

1672-
// We only want RecAddExpr with recurrence step that are constant. This
1673-
// is good enough for all the idioms we want to recognize. Later we expand
1674-
// the recurrence as {base,+,a} -> (base + a * strlen) and materialize
1672+
// We only want RecAddExpr with recurrence step that is constant. This
1673+
// is good enough for all the idioms we want to recognize. Later we expand and materialize
1674+
// the recurrence as {base,+,a} -> (base + a * strlen)
16751675
if (!dyn_cast<SCEVConstant>(AddRecEv->getStepRecurrence(*SE)))
16761676
return false;
16771677
}
@@ -1724,7 +1724,7 @@ class StrlenVerifier {
17241724
/// size_t result = str - base;
17251725
/// \endcode
17261726
///
1727-
/// will be transformed as as follow: The idiom will be replaced by a strlen
1727+
/// will be transformed as follows: The idiom will be replaced by a strlen
17281728
/// computation to compute the address of the null terminator of the string.
17291729
///
17301730
/// \code{.c}
@@ -1764,7 +1764,7 @@ bool LoopIdiomRecognize::recognizeAndInsertStrLen() {
17641764
BasicBlock *LoopExitBB = CurLoop->getExitBlock();
17651765

17661766
IRBuilder<> Builder(Preheader->getTerminator());
1767-
SCEVExpander Expander(*SE, Preheader->getModule()->getDataLayout(), "scev");
1767+
SCEVExpander Expander(*SE, Preheader->getModule()->getDataLayout(), "strlen_idiom");
17681768
Value *MaterialzedBase = Expander.expandCodeFor(
17691769
Verifier.LoadBaseEv, Verifier.LoadBaseEv->getType(),
17701770
Builder.GetInsertPoint());
@@ -1810,9 +1810,8 @@ bool LoopIdiomRecognize::recognizeAndInsertStrLen() {
18101810

18111811
// All LCSSA Loop Phi are dead, the left over dead loop body can be cleaned
18121812
// up by later passes
1813-
for (PHINode *PN : Cleanup) {
1813+
for (PHINode *PN : Cleanup)
18141814
RecursivelyDeleteDeadPHINode(PN);
1815-
}
18161815
SE->forgetLoop(CurLoop);
18171816

18181817
++NumStrLen;

0 commit comments

Comments
 (0)