]> granicus.if.org Git - llvm/commitdiff
[ImplicitNullChecks] Add a test demonstrating a case we don't get today
authorSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 26 Jan 2017 01:07:33 +0000 (01:07 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 26 Jan 2017 01:07:33 +0000 (01:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293126 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/X86/implicit-null-checks.mir

index 81351511374c412edb3ff402fd24fe0c601f4a36..d2a9e5e50a27ed9075662cd1b02fca6d6a870ca4 100644 (file)
     ret i32 0
   }
 
+  define i32 @use_alternate_load_op(i32* %ptr, i32* %ptr2) {
+  entry:
+    %ptr_is_null = icmp eq i32* %ptr, null
+    br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
+
+  not_null:
+    ret i32 undef
+
+  is_null:
+    ret i32 0
+  }
+
   attributes #0 = { "target-features"="+bmi,+bmi2" }
 
   !0 = !{}
@@ -431,3 +443,37 @@ body:             |
     RETQ %eax
 
 ...
+---
+name:            use_alternate_load_op
+# CHECK-LABEL: use_alternate_load_op
+# CHECK: bb.0.entry:
+# CHECK: TEST64rr %rdi, %rdi, implicit-def %eflags
+# CHECK-NEXT: JE_1 %bb.2.is_null, implicit killed %eflags
+# CHECK: bb.1.not_null
+
+alignment:       4
+tracksRegLiveness: true
+liveins:
+  - { reg: '%rdi' }
+  - { reg: '%rsi' }
+body:             |
+  bb.0.entry:
+    successors: %bb.2.is_null, %bb.1.not_null
+    liveins: %rdi, %rsi
+
+    TEST64rr %rdi, %rdi, implicit-def %eflags
+    JE_1 %bb.2.is_null, implicit killed %eflags
+
+  bb.1.not_null:
+    liveins: %rdi, %rsi
+
+    %rcx = MOV64rm killed %rsi, 1, _, 0, _
+    %rdx = AND64rm killed %rcx, %rdi, 1, _, 0, _, implicit-def dead %eflags
+    %r10 = MOV64rm killed %rdi, 1, _, 0, _
+    RETQ %r10d
+
+  bb.2.is_null:
+    %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
+    RETQ %eax
+
+...