[llvm-commits] [llvm] r167691 - /llvm/trunk/test/Transforms/InstCombine/memcmp-1.ll

Meador Inge meadori at codesourcery.com
Sat Nov 10 23:10:25 PST 2012


Author: meadori
Date: Sun Nov 11 01:10:25 2012
New Revision: 167691

URL: http://llvm.org/viewvc/llvm-project?rev=167691&view=rev
Log:
Remove hard-coded constant in Transforms/InstCombine/memcmp-1.ll

Transforms/InstCombine/memcmp-1.ll has a test case that looks like:

  @foo = constant [4 x i8] c"foo\00"
  @hel = constant [4 x i8] c"hel\00"

  ...

  %mem1 = getelementptr [4 x i8]* @hel, i32 0, i32 0
  %mem2 = getelementptr [4 x i8]* @foo, i32 0, i32 0
  %ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 3)
  ret i32 %ret
  ; CHECK: ret i32 2

The folded return value (2 above) is computed using the system memcmp
that the compiler is linked with.  This can return different values on
different systems.  The test was originally written on an OS X 10.7.5
x86-64 box and passed.  However, it failed on one of the x86-64 FreeBSD
buildbots because the system memcpy on that machine returned a different
value (1 instead of 2).

I fixed the test by checking the folding constants with regexes.

Modified:
    llvm/trunk/test/Transforms/InstCombine/memcmp-1.ll

Modified: llvm/trunk/test/Transforms/InstCombine/memcmp-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memcmp-1.ll?rev=167691&r1=167690&r2=167691&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/memcmp-1.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/memcmp-1.ll Sun Nov 11 01:10:25 2012
@@ -59,5 +59,14 @@
   %mem2 = getelementptr [4 x i8]* @foo, i32 0, i32 0
   %ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 3)
   ret i32 %ret
-; CHECK: ret i32 2
+; CHECK: ret i32 {{[0-9]+}}
+}
+
+define i32 @test_simplify6() {
+; CHECK: @test_simplify6
+  %mem1 = getelementptr [4 x i8]* @foo, i32 0, i32 0
+  %mem2 = getelementptr [4 x i8]* @hel, i32 0, i32 0
+  %ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 3)
+  ret i32 %ret
+; CHECK: ret i32 {{-[0-9]+}}
 }





More information about the llvm-commits mailing list