Skip to content

Commit 431cdab

Browse files
committed
[AggressiveInstCombine] Implement memchr inlining optimization
This patch implements an optimization to inline small memchr calls into a sequence of loads and comparisons when the length is below a threshold. This allows better optimization of small string searches. The implementation: Adds support for inlining memchr calls with constant length, introduces a memchr-inline-threshold parameter (default: 6), and adds test coverage for small memchr operations.
1 parent 60540c8 commit 431cdab

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,14 +1144,7 @@ static bool foldMemChr(CallInst *Call, DomTreeUpdater *DTU,
11441144
return true;
11451145
}
11461146

1147-
// Handle constant string case
1148-
StringRef Str;
1149-
Value *Base = Call->getArgOperand(0);
1150-
if (!getConstantStringInfo(Base, Str, /*TrimAtNul=*/false))
1151-
return false;
1152-
1153-
// ... rest of the existing constant string handling ...
1154-
// ... existing code ...
1147+
return false;
11551148
}
11561149

11571150
static bool foldLibCalls(Instruction &I, TargetTransformInfo &TTI,

0 commit comments

Comments
 (0)