Normalize memcmp constant folding results.
authorMeador Inge <meadori@codesourcery.com>
Mon, 12 Nov 2012 14:00:45 +0000 (14:00 +0000)
committerMeador Inge <meadori@codesourcery.com>
Mon, 12 Nov 2012 14:00:45 +0000 (14:00 +0000)
commitb3e91f6ae075ca04a8f7862782d595c363496ac7
treea7e330e876a0254fc0e8006c5034c5b9e8768842
parent582d7de7093e9d9609036dd6905f1fbdcec703e4
Normalize memcmp constant folding results.

The library call simplifier folds memcmp calls with all constant arguments
to a constant.  For example:

  memcmp("foo", "foo", 3) ->  0
  memcmp("hel", "foo", 3) ->  1
  memcmp("foo", "hel", 3) -> -1

The folding is implemented in terms of the system memcmp that LLVM gets
linked with.  It currently just blindly uses the value returned from
the system memcmp as the folded constant.

This patch normalizes the values returned from the system memcmp to
(-1, 0, 1) so that we get consistent results across multiple platforms.
The test cases were adjusted accordingly.

llvm-svn: 167726
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/memcmp-1.ll