aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-19 04:17:36 +0000
committerChris Lattner <sabre@nondot.org>2009-06-19 04:17:36 +0000
commit849832c0fb47f4e111840e0031b9129d41ffb389 (patch)
treef2b648db29f164ed6365a3a316baa7de17063eb9 /lib/Transforms/Scalar/SimplifyLibCalls.cpp
parent10382fb71d8306f320ecbeb7049d25354c0e5457 (diff)
part of PR4405: disable a contentious optimization for
strcmp -> memcmp when the lengths of the strings are unknown. Patch by Nick Lewycky! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/SimplifyLibCalls.cpp')
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index 7d0c35e540..bbcb79255e 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -709,12 +709,10 @@ struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
// strcmp(P, "x") -> memcmp(P, "x", 2)
uint64_t Len1 = GetStringLength(Str1P);
uint64_t Len2 = GetStringLength(Str2P);
- if (Len1 || Len2) {
- // Choose the smallest Len excluding 0 which means 'unknown'.
- if (!Len1 || (Len2 && Len2 < Len1))
- Len1 = Len2;
+ if (Len1 && Len2) {
return EmitMemCmp(Str1P, Str2P,
- ConstantInt::get(TD->getIntPtrType(), Len1), B);
+ ConstantInt::get(TD->getIntPtrType(),
+ std::min(Len1, Len2)), B);
}
return 0;