Use a sign-extend instead of a zero-extend when promoting a
authorDan Gohman <gohman@apple.com>
Wed, 18 Feb 2009 17:22:41 +0000 (17:22 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 18 Feb 2009 17:22:41 +0000 (17:22 +0000)
commitf5a309e989b8d2199cb542793e9edf48395d9fed
treec52543300d485f04baebd2bc1ee8f1fb7721a411
parentcad24c9abc834db5cf8f92019f99370507d8d07a
Use a sign-extend instead of a zero-extend when promoting a
trip count value when the original loop iteration condition is
signed and the canonical induction variable won't undergo signed
overflow. This isn't required for correctness; it just preserves
more information about original loop iteration values.

Add a getTruncateOrSignExtend method to ScalarEvolution,
following getTruncateOrZeroExtend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64918 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ScalarEvolution.h
lib/Analysis/ScalarEvolution.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
test/Transforms/IndVarSimplify/preserve-signed-wrap.ll
test/Transforms/IndVarSimplify/promote-iv-to-eliminate-casts.ll
test/Transforms/IndVarSimplify/signed-trip-count.ll [new file with mode: 0644]