[InstCombine] Fix a bug when combining `icmp` from `ptrtoint`
authorMichael Liao <michael.liao@intel.com>
Fri, 13 Feb 2015 04:51:26 +0000 (04:51 +0000)
committerMichael Liao <michael.liao@intel.com>
Fri, 13 Feb 2015 04:51:26 +0000 (04:51 +0000)
commit4235574ce3c02c2c8ba8885a61a4f056cf30f4c4
treee8db49c45ec2499002d3be4facb3f31ac67d04ed
parente95568c0a020e05ae7a42c5695b3793b313e69f1
[InstCombine] Fix a bug when combining `icmp` from `ptrtoint`

- First, there's a crash when we try to combine that pointers into `icmp`
  directly by creating a `bitcast`, which is invalid if that two pointers are
  from different address spaces.

- It's not always appropriate to cast one pointer to another if they are from
  different address spaces as that is not no-op cast. Instead, we only combine
  `icmp` from `ptrtoint` if that two pointers are of the same address space.

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