[JumpThreading] Simplify comparisons when simplifying branches
authorPhilip Reames <listmail@philipreames.com>
Thu, 7 May 2015 00:19:14 +0000 (00:19 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 7 May 2015 00:19:14 +0000 (00:19 +0000)
commit16e7e690b7b57cc68e0024300a0e667937b3c6d9
treef96bdaaa4d00e9be980ed37abb52e31e5a348395
parent49204878d7002f846313f40e6a7dd046ddb7341b
[JumpThreading] Simplify comparisons when simplifying branches

If we have recognized that a conditional is constant at a particular location in the code (while trying to decide if we can simplify a conditional branch), we can eagerly replace that condition with a constant if it's definition is post dominated by the branch in question.

In practice, this ends up being a compile time savings at most. JumpThreading would have visited each using branch anyways. CVP would have visited the cmp itself again. Unless LVI gives up early, we shouldn't gain any addition power by doing this transformation early. What we do gain is simplicity and compile time.

Differential Revision: http://reviews.llvm.org/D9312

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236684 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/JumpThreading.cpp
test/Transforms/JumpThreading/thread-cmp.ll [new file with mode: 0644]