implement the first part of PR8882: when lowering an inbounds
authorChris Lattner <sabre@nondot.org>
Thu, 10 Feb 2011 07:11:16 +0000 (07:11 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 10 Feb 2011 07:11:16 +0000 (07:11 +0000)
commit6cdf2ea98e9952a57768a1fcdce8850089263260
tree9e4aba745da2c2ade020bbd6c284111076e96177
parent81baf14fdfa29c22a08d609144c285169e23a247
implement the first part of PR8882: when lowering an inbounds
gep to explicit addressing, we know that none of the intermediate
computation overflows.

This could use review: it seems that the shifts certainly wouldn't
overflow, but could the intermediate adds overflow if there is a
negative index?

Previously the testcase would instcombine to:

define i1 @test(i64 %i) {
  %p1.idx.mask = and i64 %i, 4611686018427387903
  %cmp = icmp eq i64 %p1.idx.mask, 1000
  ret i1 %cmp
}

now we get:

define i1 @test(i64 %i) {
  %cmp = icmp eq i64 %i, 1000
  ret i1 %cmp
}

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125271 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/icmp.ll
test/Transforms/InstCombine/sub.ll