[BasicAA] Add test for incorrect non-negative logic (NFC)

This commit is contained in:
Nikita Popov 2021-10-25 18:01:03 +02:00
parent 5fb46a9fa3
commit 7e97347409

View File

@ -130,5 +130,20 @@ define void @symmetry([0 x i8]* %ptr, i32 %a, i32 %b, i32 %c) {
ret void
}
; TODO: %ptr.neg and %ptr.shl may alias, as the shl renders the previously
; non-negative value potentially negative.
define void @shl_of_non_negative(i8* %ptr, i64 %a) {
; CHECK-LABEL: Function: shl_of_non_negative
; CHECK: NoAlias: i8* %ptr.a, i8* %ptr.neg
; CHECK: NoAlias: i8* %ptr.neg, i8* %ptr.shl
%a.cmp = icmp sge i64 %a, 0
call void @llvm.assume(i1 %a.cmp)
%ptr.neg = getelementptr i8, i8* %ptr, i64 -2
%ptr.a = getelementptr i8, i8* %ptr, i64 %a
%shl = shl i64 %a, 1
%ptr.shl = getelementptr i8, i8* %ptr, i64 %shl
ret void
}
declare void @llvm.assume(i1 %cond)
declare void @barrier()