[InstCombine] don't assume 'inbounds' for bitcast deref or null pointer in non-default address space

Follow-up to D68244 to account for a corner case discussed in:
https://bugs.llvm.org/show_bug.cgi?id=43501

Add one more restriction: if the pointer is deref-or-null and in a non-default
(non-zero) address space, we can't assume inbounds.

Differential Revision: https://reviews.llvm.org/D68706

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374728 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjay Patel
2019-10-13 17:19:08 +00:00
parent c45f92289b
commit 3b2a5e76e1
2 changed files with 12 additions and 4 deletions
@@ -100,11 +100,11 @@ define float @matching_scalar_smallest_deref_addrspace(<4 x float> addrspace(4)*
ret float %r
}
; TODO: Is a null pointer inbounds in any address space?
; A null pointer can't be assumed inbounds in a non-default address space.
define float @matching_scalar_smallest_deref_or_null_addrspace(<4 x float> addrspace(4)* dereferenceable_or_null(1) %p) {
; CHECK-LABEL: @matching_scalar_smallest_deref_or_null_addrspace(
; CHECK-NEXT: [[BC:%.*]] = getelementptr inbounds <4 x float>, <4 x float> addrspace(4)* [[P:%.*]], i64 0, i64 0
; CHECK-NEXT: [[BC:%.*]] = getelementptr <4 x float>, <4 x float> addrspace(4)* [[P:%.*]], i64 0, i64 0
; CHECK-NEXT: [[R:%.*]] = load float, float addrspace(4)* [[BC]], align 16
; CHECK-NEXT: ret float [[R]]
;