diff options
author | Kai Nacke <kai.nacke@redstar.de> | 2014-02-04 05:55:16 +0000 |
---|---|---|
committer | Kai Nacke <kai.nacke@redstar.de> | 2014-02-04 05:55:16 +0000 |
commit | a56bb7802199d3202535de2c44ea253dbc18f0b6 (patch) | |
tree | 68718304251a52674d7b151eb0a531622c766ca3 /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | |
parent | 5e8c30f19234865c8f4ce7b202fc782127ad77de (diff) | |
download | bcm5719-llvm-a56bb7802199d3202535de2c44ea253dbc18f0b6.tar.gz bcm5719-llvm-a56bb7802199d3202535de2c44ea253dbc18f0b6.zip |
Add strchr(p, 0) -> p + strlen(p) to SimplifyLibCalls
Add the missing transformation strchr(p, 0) -> p + strlen(p) to SimplifyLibCalls
and remove the ToDo comment.
Reviewer: Duncan P.N. Exan Smith
llvm-svn: 200736
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 36d24624f94..1ef81159457 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -493,8 +493,11 @@ struct StrChrOpt : public LibCallOptimization { // Otherwise, the character is a constant, see if the first argument is // a string literal. If so, we can constant fold. StringRef Str; - if (!getConstantStringInfo(SrcStr, Str)) + if (!getConstantStringInfo(SrcStr, Str)) { + if (TD && CharC->isZero()) // strchr(p, 0) -> p + strlen(p) + return B.CreateGEP(SrcStr, EmitStrLen(SrcStr, B, TD, TLI), "strchr"); return 0; + } // Compute the offset, make sure to handle the case when we're searching for // zero (a weird way to spell strlen). @@ -2297,8 +2300,6 @@ void LibCallSimplifier::replaceAllUsesWith(Instruction *I, Value *With) const { // * sqrt(Nroot(x)) -> pow(x,1/(2*N)) // * sqrt(pow(x,y)) -> pow(|x|,y*0.5) // -// strchr: -// * strchr(p, 0) -> strlen(p) // tan, tanf, tanl: // * tan(atan(x)) -> x // |