[ValueTracking] Add a new predicate: isKnownNonEqual()
authorJames Molloy <james.molloy@arm.com>
Thu, 22 Oct 2015 13:18:42 +0000 (13:18 +0000)
committerJames Molloy <james.molloy@arm.com>
Thu, 22 Oct 2015 13:18:42 +0000 (13:18 +0000)
commitaf1480aea6dc3e393e8acc02feba65b4ad7e2b10
treef252994cc36be6fdf48a8e276b54d869553806b8
parentb217a9a460e8e147f482b117b6a86d3e152cdef1
[ValueTracking] Add a new predicate: isKnownNonEqual()

isKnownNonEqual(A, B) returns true if it can be determined that A != B.

At the moment it only knows two facts, that a non-wrapping add of nonzero to a value cannot be that value:

A + B != A [where B != 0, addition is nsw or nuw]

and that contradictory known bits imply two values are not equal.

This patch also hooks this up to InstSimplify; InstSimplify had a peephole for the first fact but not the second so this teaches InstSimplify a new trick too (alas no measured performance impact!)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251012 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Analysis/ValueTracking.h
lib/Analysis/InstructionSimplify.cpp
lib/Analysis/ValueTracking.cpp
test/Analysis/ValueTracking/known-non-equal.ll [new file with mode: 0644]