diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-02-01 16:04:21 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-02-01 16:04:21 +0000 |
| commit | 08da2e28eebe4f1f3ef0beef91a83287e9b3b352 (patch) | |
| tree | f7696b53a3319c4a0bb903191f9882b3afec2cb9 /llvm/test/CodeGen/X86/implicit-null-checks.mir | |
| parent | b5bc933c295c7168c8cc4e068a6b2f8d20407e75 (diff) | |
| download | bcm5719-llvm-08da2e28eebe4f1f3ef0beef91a83287e9b3b352.tar.gz bcm5719-llvm-08da2e28eebe4f1f3ef0beef91a83287e9b3b352.zip | |
[ImplicitNullCheck] Extend canReorder scope
Summary:
This change allows a re-order of two intructions if their uses
are overlapped.
Patch by Serguei Katkov!
Reviewers: reames, sanjoy
Reviewed By: sanjoy
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D29120
llvm-svn: 293775
Diffstat (limited to 'llvm/test/CodeGen/X86/implicit-null-checks.mir')
| -rw-r--r-- | llvm/test/CodeGen/X86/implicit-null-checks.mir | 96 |
1 files changed, 94 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/X86/implicit-null-checks.mir b/llvm/test/CodeGen/X86/implicit-null-checks.mir index d2a9e5e50a2..af9758fc8ad 100644 --- a/llvm/test/CodeGen/X86/implicit-null-checks.mir +++ b/llvm/test/CodeGen/X86/implicit-null-checks.mir @@ -145,6 +145,35 @@ attributes #0 = { "target-features"="+bmi,+bmi2" } + define i32 @imp_null_check_gep_load_with_use_dep(i32* %x, i32 %a) { + entry: + %c = icmp eq i32* %x, null + br i1 %c, label %is_null, label %not_null, !make.implicit !0 + + is_null: ; preds = %entry + ret i32 42 + + not_null: ; preds = %entry + %x.loc = getelementptr i32, i32* %x, i32 1 + %y = ptrtoint i32* %x.loc to i32 + %b = add i32 %a, %y + %t = load i32, i32* %x + %z = add i32 %t, %b + ret i32 %z + } + + define i32 @imp_null_check_load_with_base_sep(i32* %x, i32 %a) { + entry: + %c = icmp eq i32* %x, null + br i1 %c, label %is_null, label %not_null, !make.implicit !0 + + is_null: ; preds = %entry + ret i32 42 + + not_null: ; preds = %entry + ret i32 undef + } + !0 = !{} ... --- @@ -447,8 +476,8 @@ body: | 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: %r10 = FAULTING_LOAD_OP %bb.2.is_null, {{[0-9]+}}, killed %rdi, 1, _, 0, _ +# CHECK-NEXT: JMP_1 %bb.1.not_null # CHECK: bb.1.not_null alignment: 4 @@ -477,3 +506,66 @@ body: | RETQ %eax ... +--- +name: imp_null_check_gep_load_with_use_dep +# CHECK: bb.0.entry: +# CHECK: %eax = FAULTING_LOAD_OP %bb.2.is_null, {{[0-9]+}}, killed %rdi, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.x) +# CHECK-NEXT: JMP_1 %bb.1.not_null +alignment: 4 +tracksRegLiveness: true +liveins: + - { reg: '%rdi' } + - { reg: '%rsi' } +body: | + bb.0.entry: + successors: %bb.1.is_null(0x30000000), %bb.2.not_null(0x50000000) + liveins: %rsi, %rdi + + TEST64rr %rdi, %rdi, implicit-def %eflags + JE_1 %bb.1.is_null, implicit %eflags + + bb.2.not_null: + liveins: %rdi, %rsi + + %rsi = ADD64rr %rsi, %rdi, implicit-def dead %eflags + %eax = MOV32rm killed %rdi, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.x) + %eax = LEA64_32r killed %rax, 1, killed %rsi, 4, _ + RETQ %eax + + bb.1.is_null: + %eax = MOV32ri 42 + RETQ %eax + +... +--- +name: imp_null_check_load_with_base_sep +# CHECK: bb.0.entry: +# CHECK: %rsi = ADD64rr %rsi, %rdi, implicit-def dead %eflags +# CHECK-NEXT: %esi = FAULTING_LOAD_OP %bb.2.is_null, {{[0-9]+}}, killed %esi, %rdi, 1, _, 0, _, implicit-def dead %eflags +# CHECK-NEXT: JMP_1 %bb.1.not_null +alignment: 4 +tracksRegLiveness: true +liveins: + - { reg: '%rdi' } + - { reg: '%rsi' } +body: | + bb.0.entry: + successors: %bb.1.is_null(0x30000000), %bb.2.not_null(0x50000000) + liveins: %rsi, %rdi + + TEST64rr %rdi, %rdi, implicit-def %eflags + JE_1 %bb.1.is_null, implicit %eflags + + bb.2.not_null: + liveins: %rdi, %rsi + + %rsi = ADD64rr %rsi, %rdi, implicit-def dead %eflags + %esi = AND32rm killed %esi, %rdi, 1, _, 0, _, implicit-def dead %eflags + %eax = MOV32rr %esi + RETQ %eax + + bb.1.is_null: + %eax = MOV32ri 42 + RETQ %eax + +... |

