implement constant folding support for an exotic constant expr:
authorChris Lattner <sabre@nondot.org>
Thu, 6 Jan 2011 06:19:46 +0000 (06:19 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 6 Jan 2011 06:19:46 +0000 (06:19 +0000)
commit8cd4efb6a5e51b4e77039c17338f290ca3a8ee92
treeae17d657a282344d56741b227bebecd9246785e7
parent255874ff521bb81b294ec861a5d9a99d8198448c
implement constant folding support for an exotic constant expr:
  ret i64 ptrtoint (i8* getelementptr ([1000 x i8]* @X, i64 1, i64 sub (i64 0, i64 ptrtoint ([1000 x i8]* @X to i64))) to i64)

to "ret i64 1000".  This allows us to correctly compute the trip count
on a loop in PR8883, which occurs with std::fill on a char array.  This
allows us to transform it into a memset with a constant size.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122950 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ConstantFolding.cpp
test/Transforms/InstCombine/constant-fold-gep.ll