OSDN Git Service

[InstCombine] Simplify a known nonzero incoming value of PHI
authorJun Bum Lim <junbuml@codeaurora.org>
Thu, 11 Feb 2016 15:50:07 +0000 (15:50 +0000)
committerJun Bum Lim <junbuml@codeaurora.org>
Thu, 11 Feb 2016 15:50:07 +0000 (15:50 +0000)
commit885a68b0cf48628f853509b9fee566617fc82b14
tree3b3e9bee62892393b6046a042877473b323eed25
parenta25f0be03ba4676dd8530f4ad9df359e8e5347b0
[InstCombine] Simplify a known nonzero incoming value of PHI

Summary:
When a PHI is used only to be compared with zero, it is possible to replace an
incoming value with any non-zero constant if the incoming value can be proved as
a known nonzero value. For example, in below code, we can replace the incoming value %v with
any non-zero constant based on the fact that the PHI is only used to be compared with zero
and %v is a known non-zero value:
  %v = select %cond, 1, 2
  %p = phi [%v, BB] ...
  %c = icmp eq, %p, 0

Reviewers: mcrosier, jmolloy, sanjoy

Subscribers: hfinkel, mcrosier, majnemer, llvm-commits, haicheng, bmakam, mssimpso, gberry

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260530 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombinePHI.cpp
test/Transforms/InstCombine/phi.ll