[llvm] f4199b8 - [SCCP] Add assume non null test (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 25 07:03:48 PDT 2020


Author: Nikita Popov
Date: 2020-07-25T16:02:15+02:00
New Revision: f4199b8f0bdbea12ff69dbb78336a05894f81a8c

URL: https://github.com/llvm/llvm-project/commit/f4199b8f0bdbea12ff69dbb78336a05894f81a8c
DIFF: https://github.com/llvm/llvm-project/commit/f4199b8f0bdbea12ff69dbb78336a05894f81a8c.diff

LOG: [SCCP] Add assume non null test (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/SCCP/assume.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SCCP/assume.ll b/llvm/test/Transforms/SCCP/assume.ll
index 764c1737c287..dc827f03c0ab 100644
--- a/llvm/test/Transforms/SCCP/assume.ll
+++ b/llvm/test/Transforms/SCCP/assume.ll
@@ -46,3 +46,30 @@ define void @basic(i32 %v) {
   call void @use(i1 %c8)
   ret void
 }
+
+define void @nonnull(i32* %v) {
+; CHECK-LABEL: @nonnull(
+; CHECK-NEXT:    [[A:%.*]] = icmp ne i32* [[V:%.*]], null
+; CHECK-NEXT:    call void @llvm.assume(i1 [[A]])
+; CHECK-NEXT:    [[C1:%.*]] = icmp eq i32* [[V]], null
+; CHECK-NEXT:    call void @use(i1 [[C1]])
+; CHECK-NEXT:    [[C2:%.*]] = icmp ne i32* [[V]], null
+; CHECK-NEXT:    call void @use(i1 [[C2]])
+; CHECK-NEXT:    [[C3:%.*]] = icmp eq i32* null, [[V]]
+; CHECK-NEXT:    call void @use(i1 [[C3]])
+; CHECK-NEXT:    [[C4:%.*]] = icmp ne i32* null, [[V]]
+; CHECK-NEXT:    call void @use(i1 [[C4]])
+; CHECK-NEXT:    ret void
+;
+  %a = icmp ne i32* %v, null
+  call void @llvm.assume(i1 %a)
+  %c1 = icmp eq i32* %v, null
+  call void @use(i1 %c1)
+  %c2 = icmp ne i32* %v, null
+  call void @use(i1 %c2)
+  %c3 = icmp eq i32* null, %v
+  call void @use(i1 %c3)
+  %c4 = icmp ne i32* null, %v
+  call void @use(i1 %c4)
+  ret void
+}


        


More information about the llvm-commits mailing list