xref: /llvm-project/llvm/test/CodeGen/X86/implicit-null-chk-reg-rewrite.mir (revision 60442f0d442723a487528bdd8b48b24657a025e8)
1# RUN: llc -mtriple=x86_64 -run-pass=implicit-null-checks %s -o - | FileCheck %s
2--- |
3
4  define i32 @reg-rewrite(ptr %x) {
5  entry:
6    br i1 undef, label %is_null, label %not_null, !make.implicit !0
7
8  is_null:
9    ret i32 42
10
11  not_null:
12    ret i32 100
13  }
14
15  !0 = !{}
16
17...
18---
19# Check that the TEST instruction is replaced with
20# FAULTING_OP only if there are no instructions
21# between the TEST and conditional jump
22# that clobber the register used in TEST.
23name:            reg-rewrite
24
25alignment:       16
26tracksRegLiveness: true
27liveins:
28  - { reg: '$rdi' }
29
30body:             |
31  bb.0.entry:
32    liveins: $rdi
33
34    TEST64rr $rdi, $rdi, implicit-def $eflags
35    ; CHECK-LABEL: bb.0.entry
36    ; CHECK-NOT: FAULTING_OP
37    renamable $rdi = MOV64ri 5000
38    JCC_1 %bb.2, 4, implicit $eflags
39
40  bb.1.not_null:
41    liveins: $rdi, $rsi
42
43    $rax = MOV64rm renamable $rdi, 1, $noreg, 4, $noreg
44    RET64 $eax
45
46  bb.2.is_null:
47    $eax = MOV32ri 200
48    RET64 $eax
49...
50