[llvm-commits] [llvm] r73751 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyLibCalls.cpp test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll

Chris Lattner sabre at nondot.org
Thu Jun 18 21:17:36 PDT 2009


Author: lattner
Date: Thu Jun 18 23:17:36 2009
New Revision: 73751

URL: http://llvm.org/viewvc/llvm-project?rev=73751&view=rev
Log:
part of PR4405: disable a contentious optimization for
strcmp -> memcmp when the lengths of the strings are unknown.

Patch by Nick Lewycky!

Removed:
    llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=73751&r1=73750&r2=73751&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Thu Jun 18 23:17:36 2009
@@ -709,12 +709,10 @@
     // 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;

Removed: llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll?rev=73750&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyLibCalls/2008-12-20-StrcmpMemcmp.ll (removed)
@@ -1,10 +0,0 @@
-; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | grep call.*memcmp
-
- at .str = internal constant [2 x i8] c"x\00"
-
-declare i32 @strcmp(i8* %dest, i8* %src)
-
-define i32 @foo(i8* %x, i8* %y) {
-  %A = call i32 @strcmp(i8* %x, i8* getelementptr ([2 x i8]* @.str, i32 0, i32 0))
-  ret i32 %A
-}





More information about the llvm-commits mailing list