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
This commit is contained in:
Chris Lattner
2011-02-10 07:11:16 +00:00
parent 81baf14fdf
commit 6cdf2ea98e
3 changed files with 33 additions and 10 deletions

View File

@@ -256,7 +256,7 @@ define i64 @test24b(i8* %P, i64 %A){
%G = sub i64 %C, ptrtoint ([42 x i16]* @Arr to i64)
ret i64 %G
; CHECK: @test24b
; CHECK-NEXT: shl i64 %A, 1
; CHECK-NEXT: shl nuw i64 %A, 1
; CHECK-NEXT: ret i64
}
@@ -267,7 +267,7 @@ define i64 @test25(i8* %P, i64 %A){
%G = sub i64 %C, ptrtoint (i16* getelementptr ([42 x i16]* @Arr, i64 1, i64 0) to i64)
ret i64 %G
; CHECK: @test25
; CHECK-NEXT: shl i64 %A, 1
; CHECK-NEXT: shl nuw i64 %A, 1
; CHECK-NEXT: add i64 {{.*}}, -84
; CHECK-NEXT: ret i64
}