Skip to content

Commit 074099d

Browse files
committed
[CVP] Add more tests. NFC.
1 parent 498ac15 commit 074099d

File tree

1 file changed

+30
-0
lines changed
  • llvm/test/Transforms/CorrelatedValuePropagation

1 file changed

+30
-0
lines changed

llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,21 @@ entry:
384384
ret i1 %nonnull
385385
}
386386

387+
define i1 @test_known_nonnull_at_callsite_gep_inbounds(ptr %src, i64 %x) {
388+
; CHECK-LABEL: @test_known_nonnull_at_callsite_gep_inbounds(
389+
; CHECK-NEXT: entry:
390+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[SRC:%.*]], i64 [[X:%.*]]
391+
; CHECK-NEXT: call void @callee(ptr noundef nonnull [[GEP]])
392+
; CHECK-NEXT: [[NONNULL:%.*]] = icmp eq ptr [[SRC]], null
393+
; CHECK-NEXT: ret i1 false
394+
;
395+
entry:
396+
%gep = getelementptr inbounds i8, ptr %src, i64 %x
397+
call void @callee(ptr noundef nonnull %gep)
398+
%nonnull = icmp eq ptr %src, null
399+
ret i1 %nonnull
400+
}
401+
387402
; Negative tests
388403

389404
define i1 @test_known_nonnull_at_callsite_without_noundef(ptr %src) {
@@ -412,6 +427,21 @@ entry:
412427
ret i1 %nonnull
413428
}
414429

430+
define i1 @test_known_nonnull_at_callsite_gep_without_inbounds(ptr %src, i64 %x) {
431+
; CHECK-LABEL: @test_known_nonnull_at_callsite_gep_without_inbounds(
432+
; CHECK-NEXT: entry:
433+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 [[X:%.*]]
434+
; CHECK-NEXT: call void @callee(ptr noundef nonnull [[GEP]])
435+
; CHECK-NEXT: [[NONNULL:%.*]] = icmp eq ptr [[SRC]], null
436+
; CHECK-NEXT: ret i1 false
437+
;
438+
entry:
439+
%gep = getelementptr i8, ptr %src, i64 %x
440+
call void @callee(ptr noundef nonnull %gep)
441+
%nonnull = icmp eq ptr %src, null
442+
ret i1 %nonnull
443+
}
444+
415445
declare void @callee(ptr)
416446
declare void @callee2(ptr noundef)
417447

0 commit comments

Comments
 (0)