[PowerPC] Recommit r314244 with refactoring and off by default
[llvm-core.git] / test / CodeGen / X86 / implicit-null-checks.mir
blobdf89e4f6bfad55aba036161d7e0d70664d45f0c9
1 # RUN: llc -run-pass implicit-null-checks -mtriple=x86_64-apple-macosx -o - %s | FileCheck %s
3 --- |
4   target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5   target triple = "x86_64-apple-macosx"
7   ;; Positive test
8   define i32 @imp_null_check_with_bitwise_op_0(i32* %x, i32 %val) {
9   entry:
10     br i1 undef, label %is_null, label %not_null, !make.implicit !0
12   is_null:
13     ret i32 42
15   not_null:
16     br i1 undef, label %ret_100, label %ret_200
18   ret_100:
19     ret i32 100
21   ret_200:
22     ret i32 200
23   }
25   ;; Negative test.  The regalloc is such that we cannot hoist the
26   ;; instruction materializing 2200000 into %eax
27   define i32 @imp_null_check_with_bitwise_op_1(i32* %x, i32 %val, i32* %ptr) {
28   entry:
29     br i1 undef, label %is_null, label %not_null, !make.implicit !0
31   is_null:
32     ret i32 undef
34   not_null:
35     br i1 undef, label %ret_100, label %ret_200
37   ret_100:
38     ret i32 100
40   ret_200:
41     ret i32 200
42   }
44   ;; Negative test: IR is identical to
45   ;; @imp_null_check_with_bitwise_op_0 but MIR differs.
46   define i32 @imp_null_check_with_bitwise_op_2(i32* %x, i32 %val) {
47   entry:
48     br i1 undef, label %is_null, label %not_null, !make.implicit !0
50   is_null:
51     ret i32 42
53   not_null:
54     br i1 undef, label %ret_100, label %ret_200
56   ret_100:
57     ret i32 100
59   ret_200:
60     ret i32 200
61   }
63   ;; Negative test: IR is identical to
64   ;; @imp_null_check_with_bitwise_op_0 but MIR differs.
65   define i32 @imp_null_check_with_bitwise_op_3(i32* %x, i32 %val) {
66   entry:
67     br i1 undef, label %is_null, label %not_null, !make.implicit !0
69   is_null:
70     ret i32 42
72   not_null:
73     br i1 undef, label %ret_100, label %ret_200
75   ret_100:
76     ret i32 100
78   ret_200:
79     ret i32 200
80   }
82   ;; Positive test
83   define i32 @imp_null_check_with_bitwise_op_4(i32* %x, i32 %val) {
84   entry:
85     br i1 undef, label %is_null, label %not_null, !make.implicit !0
87   is_null:
88     ret i32 42
90   not_null:
91     br i1 undef, label %ret_100, label %ret_200
93   ret_100:
94     ret i32 100
96   ret_200:
97     ret i32 200
98   }
100   declare void @f() readonly
102   define i32 @no_hoist_across_call(i32* %ptr) {
103   entry:
104     %is_null = icmp eq i32* %ptr, null
105     br i1 %is_null, label %leave, label %stay, !make.implicit !0
107   stay:
108     call void @f()
109     %val = load i32, i32* %ptr
110     ret i32 %val
112   leave:
113     ret i32 0
114   }
116   define i32 @dependency_live_in_hazard(i32* %ptr, i32** %ptr2, i32* %ptr3) #0 {
117   entry:
118     %val = load i32*, i32** %ptr2
119     %ptr_is_null = icmp eq i32* %ptr, null
120     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
122   not_null:                                         ; preds = %entry
123     %addend = load i32, i32* %val
124     %result = load i32, i32* %ptr
125     %result.shr = lshr i32 %result, 4
126     %result.and = and i32 %result.shr, 4095
127     %result.add = add i32 %addend, %result.and
128     ret i32 %result.add
130   is_null:                                          ; preds = %entry
131     ret i32 0
132   }
134   define i32 @use_alternate_load_op(i32* %ptr, i32* %ptr2) {
135   entry:
136     %ptr_is_null = icmp eq i32* %ptr, null
137     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
139   not_null:
140     ret i32 undef
142   is_null:
143     ret i32 0
144   }
146   define i32 @imp_null_check_gep_load_with_use_dep(i32* %x, i32 %a) {
147   entry:
148     %c = icmp eq i32* %x, null
149     br i1 %c, label %is_null, label %not_null, !make.implicit !0
150   
151   is_null:                                          ; preds = %entry
152     ret i32 42
153   
154   not_null:                                         ; preds = %entry
155     %x.loc = getelementptr i32, i32* %x, i32 1
156     %y = ptrtoint i32* %x.loc to i32
157     %b = add i32 %a, %y
158     %t = load i32, i32* %x
159     %z = add i32 %t, %b
160     ret i32 %z
161   }
163   define i32 @imp_null_check_load_with_base_sep(i32* %x, i32 %a) {
164   entry:
165     %c = icmp eq i32* %x, null
166     br i1 %c, label %is_null, label %not_null, !make.implicit !0
167   
168   is_null:                                          ; preds = %entry
169     ret i32 42
170   
171   not_null:                                         ; preds = %entry
172     ret i32 undef
173   }
175   define void @inc_store(i32* %ptr, i32 %val) {
176   entry:
177     %ptr_is_null = icmp eq i32* %ptr, null
178     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
180   not_null:
181     ret void
183   is_null:
184     ret void
185   }
187   define void @inc_store_plus_offset(i32* %ptr, i32 %val) {
188   entry:
189     %ptr_is_null = icmp eq i32* %ptr, null
190     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
192   not_null:
193     ret void
195   is_null:
196     ret void
197   }
199   define void @inc_store_with_dep(i32* %ptr, i32 %val) {
200   entry:
201     %ptr_is_null = icmp eq i32* %ptr, null
202     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
204   not_null:
205     ret void
207   is_null:
208     ret void
209   }
211   define i32 @inc_store_with_dep_in_null(i32* %ptr, i32 %val) {
212   entry:
213     %ptr_is_null = icmp eq i32* %ptr, null
214     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
216   not_null:
217     ret i32 undef
219   is_null:
220     ret i32 undef
221   }
223   define void @inc_store_with_volatile(i32* %ptr, i32 %val) {
224   entry:
225     %ptr_is_null = icmp eq i32* %ptr, null
226     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
228   not_null:
229     ret void
231   is_null:
232     ret void
233   }
235   define void @inc_store_with_two_dep(i32* %ptr, i32 %val) {
236   entry:
237     %ptr_is_null = icmp eq i32* %ptr, null
238     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
240   not_null:
241     ret void
243   is_null:
244     ret void
245   }
247   define void @inc_store_with_redefined_base(i32* %ptr, i32 %val) {
248   entry:
249     %ptr_is_null = icmp eq i32* %ptr, null
250     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
252   not_null:
253     ret void
255   is_null:
256     ret void
257   }
259   define i32 @inc_store_with_reused_base(i32* %ptr, i32 %val) {
260   entry:
261     %ptr_is_null = icmp eq i32* %ptr, null
262     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
264   not_null:
265     ret i32 undef
267   is_null:
268     ret i32 undef
269   }
271   define i32 @inc_store_across_call(i32* %ptr) {
272   entry:
273     %ptr_is_null = icmp eq i32* %ptr, null
274     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
276   not_null:
277     call void @f()
278     ret i32 undef
280   is_null:
281     ret i32 undef
282   }
284   define i32 @inc_store_with_dep_in_dep(i32* %ptr, i32 %val) {
285   entry:
286     %ptr_is_null = icmp eq i32* %ptr, null
287     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
289   not_null:
290     ret i32 undef
292   is_null:
293     ret i32 undef
294   }
296   define i32 @inc_store_with_load_over_store(i32* %ptr, i32* %ptr2) {
297   entry:
298     %ptr_is_null = icmp eq i32* %ptr, null
299     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
301   not_null:
302     ret i32 undef
304   is_null:
305     ret i32 undef
306   }
308   define i32 @inc_store_with_store_over_load(i32* %ptr, i32* %ptr2) {
309   entry:
310     %ptr_is_null = icmp eq i32* %ptr, null
311     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
313   not_null:
314     ret i32 undef
316   is_null:
317     ret i32 undef
318   }
320   define void @inc_store_with_store_over_store(i32* %ptr, i32* %ptr2) {
321   entry:
322     %ptr_is_null = icmp eq i32* %ptr, null
323     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
325   not_null:
326     ret void
328   is_null:
329     ret void
330   }
332   define void @inc_store_with_load_and_store(i32* %ptr, i32* %ptr2) {
333   entry:
334     %ptr_is_null = icmp eq i32* %ptr, null
335     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
337   not_null:
338     ret void
340   is_null:
341     ret void
342   }
344   define i32 @inc_store_and_load_no_alias(i32* noalias %ptr, i32* noalias %ptr2) {
345   entry:
346     %ptr_is_null = icmp eq i32* %ptr, null
347     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
349   not_null:
350     ret i32 undef
352   is_null:
353     ret i32 undef
354   }
356   define i32 @inc_store_and_load_alias(i32* %ptr, i32* %ptr2) {
357   entry:
358     %ptr_is_null = icmp eq i32* %ptr, null
359     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
361   not_null:
362     ret i32 undef
364   is_null:
365     ret i32 undef
366   }
368   define i32 @inc_spill_dep(i32* %ptr, i32 %val) {
369   entry:
370     %ptr_is_null = icmp eq i32* %ptr, null
371     br i1 %ptr_is_null, label %is_null, label %not_null, !make.implicit !0
373   not_null:
374     ret i32 undef
376   is_null:
377     ret i32 undef
378   }
380   attributes #0 = { "target-features"="+bmi,+bmi2" }
382   !0 = !{}
385 name:            imp_null_check_with_bitwise_op_0
386 # CHECK-LABEL: name:            imp_null_check_with_bitwise_op_0
387 alignment:       4
388 tracksRegLiveness: true
389 liveins:
390   - { reg: '%rdi' }
391   - { reg: '%esi' }
392 # CHECK:  bb.0.entry:
393 # CHECK:    %eax = MOV32ri 2200000
394 # CHECK-NEXT:    %eax = FAULTING_OP 1, %bb.3.is_null, {{[0-9]+}}, %eax, %rdi, 1, _, 0, _, implicit-def %eflags :: (load 4 from %ir.x)
395 # CHECK-NEXT:    JMP_1 %bb.1.not_null
397 body:             |
398   bb.0.entry:
399     liveins: %esi, %rdi
401     TEST64rr %rdi, %rdi, implicit-def %eflags
402     JE_1 %bb.3.is_null, implicit %eflags
404   bb.1.not_null:
405     liveins: %esi, %rdi
407     %eax = MOV32ri 2200000
408     %eax = AND32rm killed %eax, killed %rdi, 1, _, 0, _, implicit-def dead %eflags :: (load 4 from %ir.x)
409     CMP32rr killed %eax, killed %esi, implicit-def %eflags
410     JE_1 %bb.4.ret_100, implicit %eflags
412   bb.2.ret_200:
413     %eax = MOV32ri 200
414     RETQ %eax
416   bb.3.is_null:
417     %eax = MOV32ri 42
418     RETQ %eax
420   bb.4.ret_100:
421     %eax = MOV32ri 100
422     RETQ %eax
426 name:            imp_null_check_with_bitwise_op_1
427 alignment:       4
428 tracksRegLiveness: true
429 liveins:
430   - { reg: '%rdi' }
431   - { reg: '%esi' }
432   - { reg: '%rdx' }
433 # CHECK: bb.0.entry:
434 # CHECK:    %eax = MOV32rm killed %rdx, 1, _, 0, _ :: (volatile load 4 from %ir.ptr)
435 # CHECK-NEXT:    TEST64rr %rdi, %rdi, implicit-def %eflags
436 # CHECK-NEXT:    JE_1 %bb.3.is_null, implicit %eflags
438 body:             |
439   bb.0.entry:
440     liveins: %esi, %rdi, %rdx
442     %eax = MOV32rm killed %rdx, 1, _, 0, _ :: (volatile load 4 from %ir.ptr)
443     TEST64rr %rdi, %rdi, implicit-def %eflags
444     JE_1 %bb.3.is_null, implicit %eflags
446   bb.1.not_null:
447     liveins: %esi, %rdi
449     %eax = MOV32ri 2200000
450     %eax = AND32rm killed %eax, killed %rdi, 1, _, 0, _, implicit-def dead %eflags :: (load 4 from %ir.x)
451     CMP32rr killed %eax, killed %esi, implicit-def %eflags
452     JE_1 %bb.4.ret_100, implicit %eflags
454   bb.2.ret_200:
456     %eax = MOV32ri 200
458   bb.3.is_null:
459     liveins: %eax, %ah, %al, %ax, %bh, %bl, %bp, %bpl, %bx, %eax, %ebp, %ebx, %rax, %rbp, %rbx, %r12, %r13, %r14, %r15, %r12b, %r13b, %r14b, %r15b, %r12d, %r13d, %r14d, %r15d, %r12w, %r13w, %r14w, %r15w
461     RETQ %eax
463   bb.4.ret_100:
464     %eax = MOV32ri 100
465     RETQ %eax
469 name:            imp_null_check_with_bitwise_op_2
470 # CHECK-LABEL: name:            imp_null_check_with_bitwise_op_2
471 alignment:       4
472 tracksRegLiveness: true
473 liveins:
474   - { reg: '%rdi' }
475   - { reg: '%esi' }
476 # CHECK:  bb.0.entry:
477 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
478 # CHECK-NEXT:    JE_1 %bb.3.is_null, implicit %eflags
480 body:             |
481   bb.0.entry:
482     liveins: %esi, %rdi
484     TEST64rr %rdi, %rdi, implicit-def %eflags
485     JE_1 %bb.3.is_null, implicit %eflags
487   bb.1.not_null:
488     liveins: %esi, %rdi
490     %eax = MOV32ri 2200000
491     %eax = ADD32ri killed %eax, 100, implicit-def dead %eflags
492     %eax = AND32rm killed %eax, killed %rdi, 1, _, 0, _, implicit-def dead %eflags :: (load 4 from %ir.x)
493     CMP32rr killed %eax, killed %esi, implicit-def %eflags
494     JE_1 %bb.4.ret_100, implicit %eflags
496   bb.2.ret_200:
497     %eax = MOV32ri 200
498     RETQ %eax
500   bb.3.is_null:
501     %eax = MOV32ri 42
502     RETQ %eax
504   bb.4.ret_100:
505     %eax = MOV32ri 100
506     RETQ %eax
510 name:            imp_null_check_with_bitwise_op_3
511 # CHECK-LABEL: name:            imp_null_check_with_bitwise_op_3
512 alignment:       4
513 tracksRegLiveness: true
514 liveins:
515   - { reg: '%rdi' }
516   - { reg: '%rsi' }
517 # CHECK:  bb.0.entry:
518 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
519 # CHECK-NEXT:    JE_1 %bb.3.is_null, implicit %eflags
521 body:             |
522   bb.0.entry:
523     liveins: %rsi, %rdi
525     TEST64rr %rdi, %rdi, implicit-def %eflags
526     JE_1 %bb.3.is_null, implicit %eflags
528   bb.1.not_null:
529     liveins: %rsi, %rdi
531     %rdi  = MOV64ri 5000
532     %rdi = AND64rm killed %rdi, killed %rdi, 1, _, 0, _, implicit-def dead %eflags :: (load 4 from %ir.x)
533     CMP64rr killed %rdi, killed %rsi, implicit-def %eflags
534     JE_1 %bb.4.ret_100, implicit %eflags
536   bb.2.ret_200:
537     %eax = MOV32ri 200
538     RETQ %eax
540   bb.3.is_null:
541     %eax = MOV32ri 42
542     RETQ %eax
544   bb.4.ret_100:
545     %eax = MOV32ri 100
546     RETQ %eax
550 name:            imp_null_check_with_bitwise_op_4
551 # CHECK-LABEL: name:            imp_null_check_with_bitwise_op_4
552 alignment:       4
553 tracksRegLiveness: true
554 liveins:
555   - { reg: '%rdi' }
556   - { reg: '%rsi' }
557 # CHECK:  bb.0.entry:
558 # CHECK:  %rbx = MOV64rr %rdx
559 # CHECK-NEXT:  %rbx = FAULTING_OP 1, %bb.3.is_null, {{[0-9]+}}, %rbx, %rdi, 1, _, 0, _, implicit-def %eflags :: (load 4 from %ir.x)
561 body:             |
562   bb.0.entry:
563     liveins: %rsi, %rdi, %rdx
565     TEST64rr %rdi, %rdi, implicit-def %eflags
566     JE_1 %bb.3.is_null, implicit %eflags
568   bb.1.not_null:
569     liveins: %rsi, %rdi, %rdx
571     %rbx  = MOV64rr %rdx
572     %rbx = AND64rm killed %rbx, killed %rdi, 1, _, 0, _, implicit-def dead %eflags :: (load 4 from %ir.x)
573     %rdx = MOV64ri 0
574     CMP64rr killed %rbx, killed %rsi, implicit-def %eflags
575     JE_1 %bb.4.ret_100, implicit %eflags
577   bb.2.ret_200:
578     %eax = MOV32ri 200
579     RETQ %eax
581   bb.3.is_null:
582     %eax = MOV32ri 42
583     RETQ %eax
585   bb.4.ret_100:
586     %eax = MOV32ri 100
587     RETQ %eax
591 name:            no_hoist_across_call
592 # CHECK-LABEL: name:            no_hoist_across_call
593 alignment:       4
594 tracksRegLiveness: true
595 liveins:
596   - { reg: '%rdi' }
597 calleeSavedRegisters: [ '%bh', '%bl', '%bp', '%bpl', '%bx', '%ebp', '%ebx',
598                         '%rbp', '%rbx', '%r12', '%r13', '%r14', '%r15',
599                         '%r12b', '%r13b', '%r14b', '%r15b', '%r12d', '%r13d',
600                         '%r14d', '%r15d', '%r12w', '%r13w', '%r14w', '%r15w' ]
601 # CHECK: body:
602 # CHECK-NOT: FAULTING_OP
603 # CHECK: bb.1.stay:
604 # CHECK: CALL64pcrel32
605 body:             |
606   bb.0.entry:
607     liveins: %rdi, %rbx
609     frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp
610     CFI_INSTRUCTION def_cfa_offset 16
611     CFI_INSTRUCTION offset %rbx, -16
612     %rbx = MOV64rr %rdi
613     TEST64rr %rbx, %rbx, implicit-def %eflags
614     JE_1 %bb.2.leave, implicit killed %eflags
616   bb.1.stay:
617     liveins: %rbx
619     CALL64pcrel32 @f, csr_64, implicit %rsp, implicit-def %rsp
620     %eax = MOV32rm killed %rbx, 1, _, 0, _ :: (load 4 from %ir.ptr)
621     %rbx = POP64r implicit-def %rsp, implicit %rsp
622     RETQ %eax
624   bb.2.leave:
625     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
626     %rbx = POP64r implicit-def %rsp, implicit %rsp
627     RETQ %eax
631 name:            dependency_live_in_hazard
632 # CHECK-LABEL: name:            dependency_live_in_hazard
633 # CHECK:   bb.0.entry:
634 # CHECK-NOT: FAULTING_OP
635 # CHECK: bb.1.not_null:
637 # Make sure that the BEXTR32rm instruction below is not used to emit
638 # an implicit null check -- hoisting it will require hosting the move
639 # to %esi and we cannot do that without clobbering the use of %rsi in
640 # the first instruction in bb.1.not_null.
641 alignment:       4
642 tracksRegLiveness: true
643 liveins:
644   - { reg: '%rdi' }
645   - { reg: '%rsi' }
646 body:             |
647   bb.0.entry:
648     liveins: %rdi, %rsi
650     TEST64rr %rdi, %rdi, implicit-def %eflags
651     JE_1 %bb.2.is_null, implicit killed %eflags
653   bb.1.not_null:
654     liveins: %rdi, %rsi
656     %rcx = MOV64rm killed %rsi, 1, _, 0, _ :: (load 8 from %ir.ptr2)
657     %esi = MOV32ri 3076
658     %eax = BEXTR32rm killed %rdi, 1, _, 0, _, killed %esi, implicit-def dead %eflags :: (load 4 from %ir.ptr)
659     %eax = ADD32rm killed %eax, killed %rcx, 1, _, 0, _, implicit-def dead %eflags :: (load 4 from %ir.val)
660     RETQ %eax
662   bb.2.is_null:
663     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
664     RETQ %eax
668 name:            use_alternate_load_op
669 # CHECK-LABEL: name:            use_alternate_load_op
670 # CHECK: bb.0.entry:
671 # CHECK: %rax = FAULTING_OP 1, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 0, _
672 # CHECK-NEXT: JMP_1 %bb.1.not_null
673 # CHECK: bb.1.not_null
675 alignment:       4
676 tracksRegLiveness: true
677 liveins:
678   - { reg: '%rdi' }
679   - { reg: '%rsi' }
680 body:             |
681   bb.0.entry:
682     liveins: %rdi, %rsi
684     TEST64rr %rdi, %rdi, implicit-def %eflags
685     JE_1 %bb.2.is_null, implicit killed %eflags
687   bb.1.not_null:
688     liveins: %rdi, %rsi
690     %rcx = MOV64rm killed %rsi, 1, _, 0, _
691     %rcx = AND64rm killed %rcx, %rdi, 1, _, 0, _, implicit-def dead %eflags
692     %rax = MOV64rm killed %rdi, 1, _, 0, _
693     RETQ %eax
695   bb.2.is_null:
696     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
697     RETQ %eax
701 name:            imp_null_check_gep_load_with_use_dep
702 # CHECK-LABEL: name:            imp_null_check_gep_load_with_use_dep
703 # CHECK:  bb.0.entry:
704 # CHECK:    %eax = FAULTING_OP 1, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.x)
705 # CHECK-NEXT:    JMP_1 %bb.1.not_null
706 alignment:       4
707 tracksRegLiveness: true
708 liveins:         
709   - { reg: '%rdi' }
710   - { reg: '%rsi' }
711 body:             |
712   bb.0.entry:
713     liveins: %rsi, %rdi
714   
715     TEST64rr %rdi, %rdi, implicit-def %eflags
716     JE_1 %bb.1.is_null, implicit %eflags
717   
718   bb.2.not_null:
719     liveins: %rdi, %rsi
720   
721     %rsi = ADD64rr %rsi, %rdi, implicit-def dead %eflags
722     %eax = MOV32rm killed %rdi, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.x)
723     %eax = LEA64_32r killed %rax, 1, killed %rsi, 4, _
724     RETQ %eax
725   
726   bb.1.is_null:
727     %eax = MOV32ri 42
728     RETQ %eax
732 name:            imp_null_check_load_with_base_sep
733 # CHECK-LABEL: name:            imp_null_check_load_with_base_sep
734 # CHECK:  bb.0.entry:
735 # CHECK:     %rsi = ADD64rr %rsi, %rdi, implicit-def dead %eflags
736 # CHECK-NEXT:    %esi = FAULTING_OP 1, %bb.2.is_null, {{[0-9]+}}, %esi, %rdi, 1, _, 0, _, implicit-def %eflags
737 # CHECK-NEXT:    JMP_1 %bb.1.not_null
738 alignment:       4
739 tracksRegLiveness: true
740 liveins:         
741   - { reg: '%rdi' }
742   - { reg: '%rsi' }
743 body:             |
744   bb.0.entry:
745     liveins: %rsi, %rdi
746   
747     TEST64rr %rdi, %rdi, implicit-def %eflags
748     JE_1 %bb.1.is_null, implicit %eflags
749   
750   bb.2.not_null:
751     liveins: %rdi, %rsi
752   
753     %rsi = ADD64rr %rsi, %rdi, implicit-def dead %eflags
754     %esi = AND32rm killed %esi, %rdi, 1, _, 0, _, implicit-def dead %eflags
755     %eax = MOV32rr %esi
756     RETQ %eax
757   
758   bb.1.is_null:
759     %eax = MOV32ri 42
760     RETQ %eax
764 name:            inc_store
765 # CHECK-LABEL: name:            inc_store
766 # CHECK: bb.0.entry:
767 # CHECK:  _ = FAULTING_OP 3, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 0, _, %rsi
768 # CHECK-NEXT: JMP_1 %bb.1.not_null
769 # CHECK: bb.1.not_null
771 alignment:       4
772 tracksRegLiveness: true
773 liveins:
774   - { reg: '%rdi' }
775   - { reg: '%rsi' }
776 body:             |
777   bb.0.entry:
778     liveins: %rdi, %rsi
780     TEST64rr %rdi, %rdi, implicit-def %eflags
781     JE_1 %bb.2.is_null, implicit killed %eflags
783   bb.1.not_null:
784     liveins: %rdi, %rsi
786     MOV64mr killed %rdi, 1, _, 0, _, killed %rsi
787     RETQ
789   bb.2.is_null:
790     RETQ
794 name:            inc_store_plus_offset
795 # CHECK-LABEL: inc_store_plus_offset
796 # CHECK: bb.0.entry:
797 # CHECK:  _ = FAULTING_OP 3, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 16, _, %rsi
798 # CHECK-NEXT: JMP_1 %bb.1.not_null
799 # CHECK: bb.1.not_null
801 alignment:       4
802 tracksRegLiveness: true
803 liveins:
804   - { reg: '%rdi' }
805   - { reg: '%rsi' }
806 body:             |
807   bb.0.entry:
808     liveins: %rdi, %rsi
810     TEST64rr %rdi, %rdi, implicit-def %eflags
811     JE_1 %bb.2.is_null, implicit killed %eflags
813   bb.1.not_null:
814     liveins: %rdi, %rsi
816     MOV64mr killed %rdi, 1, _, 16, _, killed %rsi
817     RETQ
819   bb.2.is_null:
820     RETQ
824 name:            inc_store_with_dep
825 # CHECK-LABEL: inc_store_with_dep
826 # CHECK: bb.0.entry:
827 # CHECK:  %esi = ADD32rr killed %esi, killed %esi, implicit-def dead %eflags
828 # CHECK-NEXT:  _ = FAULTING_OP 3, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 16, _, %esi
829 # CHECK-NEXT: JMP_1 %bb.1.not_null
830 # CHECK: bb.1.not_null
832 alignment:       4
833 tracksRegLiveness: true
834 liveins:
835   - { reg: '%rdi' }
836   - { reg: '%rsi' }
837 body:             |
838   bb.0.entry:
839     liveins: %rdi, %rsi
841     TEST64rr %rdi, %rdi, implicit-def %eflags
842     JE_1 %bb.2.is_null, implicit killed %eflags
844   bb.1.not_null:
845     liveins: %rdi, %rsi
847     %esi = ADD32rr killed %esi, killed %esi, implicit-def dead %eflags
848     MOV32mr killed %rdi, 1, _, 16, _, killed %esi
849     RETQ
851   bb.2.is_null:
852     RETQ
856 name:            inc_store_with_dep_in_null
857 # CHECK-LABEL: inc_store_with_dep_in_null
858 # CHECK: bb.0.entry:
859 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
860 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
861 # CHECK: bb.1.not_null
863 alignment:       4
864 tracksRegLiveness: true
865 liveins:
866   - { reg: '%rdi' }
867   - { reg: '%rsi' }
868 body:             |
869   bb.0.entry:
870     liveins: %rdi, %rsi
872     TEST64rr %rdi, %rdi, implicit-def %eflags
873     JE_1 %bb.2.is_null, implicit killed %eflags
875   bb.1.not_null:
876     liveins: %rdi, %rsi
878     %esi = ADD32rr %esi, %esi, implicit-def dead %eflags
879     MOV32mr killed %rdi, 1, _, 0, _, %esi
880     %eax = MOV32rr killed %esi
881     RETQ %eax
883   bb.2.is_null:
884     liveins: %rsi
885     
886     %eax = MOV32rr killed %esi
887     RETQ %eax
891 name:            inc_store_with_volatile
892 # CHECK-LABEL: inc_store_with_volatile
893 # CHECK: bb.0.entry:
894 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
895 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
896 # CHECK: bb.1.not_null
898 alignment:       4
899 tracksRegLiveness: true
900 liveins:
901   - { reg: '%rdi' }
902   - { reg: '%rsi' }
903 body:             |
904   bb.0.entry:
905     liveins: %rdi, %rsi
907     TEST64rr %rdi, %rdi, implicit-def %eflags
908     JE_1 %bb.2.is_null, implicit killed %eflags
910   bb.1.not_null:
911     liveins: %rdi, %rsi
913     MOV32mr killed %rdi, 1, _, 0, _, killed %esi :: (volatile store 4 into %ir.ptr)
914     RETQ
916   bb.2.is_null:
917     RETQ
921 name:            inc_store_with_two_dep
922 # CHECK-LABEL: inc_store_with_two_dep
923 # CHECK: bb.0.entry:
924 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
925 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
926 # CHECK: bb.1.not_null
928 alignment:       4
929 tracksRegLiveness: true
930 liveins:
931   - { reg: '%rdi' }
932   - { reg: '%rsi' }
933 body:             |
934   bb.0.entry:
935     liveins: %rdi, %rsi
937     TEST64rr %rdi, %rdi, implicit-def %eflags
938     JE_1 %bb.2.is_null, implicit killed %eflags
940   bb.1.not_null:
941     liveins: %rdi, %rsi
943     %esi = ADD32rr killed %esi, killed %esi, implicit-def dead %eflags
944     %esi = ADD32ri killed %esi, 15, implicit-def dead %eflags
945     MOV32mr killed %rdi, 1, _, 16, _, killed %esi
946     RETQ
948   bb.2.is_null:
949     RETQ
953 name:            inc_store_with_redefined_base
954 # CHECK-LABEL: inc_store_with_redefined_base
955 # CHECK: bb.0.entry:
956 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
957 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
958 # CHECK: bb.1.not_null
960 alignment:       4
961 tracksRegLiveness: true
962 liveins:
963   - { reg: '%rdi' }
964   - { reg: '%rsi' }
965 body:             |
966   bb.0.entry:
967     liveins: %rdi, %rsi
969     TEST64rr %rdi, %rdi, implicit-def %eflags
970     JE_1 %bb.2.is_null, implicit killed %eflags
972   bb.1.not_null:
973     liveins: %rdi, %rsi
975     %rdi = ADD64rr killed %rdi, killed %rdi, implicit-def dead %eflags
976     MOV32mr killed %rdi, 1, _, 16, _, killed %esi
977     RETQ
979   bb.2.is_null:
980     RETQ
984 name:            inc_store_with_reused_base
985 # CHECK-LABEL: inc_store_with_reused_base
986 # CHECK: bb.0.entry:
987 # CHECK:  _ = FAULTING_OP 3, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 16, _, %esi
988 # CHECK-NEXT: JMP_1 %bb.1.not_null
989 # CHECK: bb.1.not_null
991 alignment:       4
992 tracksRegLiveness: true
993 liveins:
994   - { reg: '%rdi' }
995   - { reg: '%rsi' }
996 body:             |
997   bb.0.entry:
998     liveins: %rdi, %rsi
1000     TEST64rr %rdi, %rdi, implicit-def %eflags
1001     JE_1 %bb.2.is_null, implicit killed %eflags
1003   bb.1.not_null:
1004     liveins: %rdi, %rsi
1006     %rax = MOV64rr %rdi
1007     MOV32mr killed %rdi, 1, _, 16, _, killed %esi
1008     RETQ %eax
1010   bb.2.is_null:
1011     %rax = XOR64rr undef %rax, undef %rax, implicit-def dead %eflags
1012     RETQ %eax
1016 name:            inc_store_across_call
1017 # CHECK-LABEL: inc_store_across_call
1018 # CHECK: bb.0.entry:
1019 # CHECK:    TEST64rr %rbx, %rbx, implicit-def %eflags
1020 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
1021 # CHECK: bb.1.not_null
1023 alignment:       4
1024 tracksRegLiveness: true
1025 liveins:
1026   - { reg: '%rdi' }
1027 calleeSavedRegisters: [ '%bh', '%bl', '%bp', '%bpl', '%bx', '%ebp', '%ebx',
1028                         '%rbp', '%rbx', '%r12', '%r13', '%r14', '%r15',
1029                         '%r12b', '%r13b', '%r14b', '%r15b', '%r12d', '%r13d',
1030                         '%r14d', '%r15d', '%r12w', '%r13w', '%r14w', '%r15w' ]
1031 body:             |
1032   bb.0.entry:
1033     liveins: %rdi, %rbx
1035     frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp
1036     CFI_INSTRUCTION def_cfa_offset 16
1037     CFI_INSTRUCTION offset %rbx, -16
1038     %rbx = MOV64rr killed %rdi
1039     TEST64rr %rbx, %rbx, implicit-def %eflags
1040     JE_1 %bb.2.is_null, implicit killed %eflags
1042   bb.1.not_null:
1043     liveins: %rbx
1045     CALL64pcrel32 @f, csr_64, implicit %rsp, implicit-def %rsp
1046     MOV32mi %rbx, 1, _, 0, _, 20
1047     %rax = MOV64rr killed %rbx
1048     %rbx = POP64r implicit-def %rsp, implicit %rsp
1049     RETQ %eax
1051   bb.2.is_null:
1052     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
1053     %rbx = POP64r implicit-def %rsp, implicit %rsp
1054     RETQ %eax
1058 name:            inc_store_with_dep_in_dep
1059 # CHECK-LABEL: inc_store_with_dep_in_dep
1060 # CHECK: bb.0.entry:
1061 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
1062 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
1063 # CHECK: bb.1.not_null
1065 alignment:       4
1066 tracksRegLiveness: true
1067 liveins:
1068   - { reg: '%rdi' }
1069   - { reg: '%rsi' }
1070 body:             |
1071   bb.0.entry:
1072     liveins: %rdi, %rsi
1074     TEST64rr %rdi, %rdi, implicit-def %eflags
1075     JE_1 %bb.2.is_null, implicit killed %eflags
1077   bb.1.not_null:
1078     liveins: %rdi, %rsi
1080     %eax = MOV32rr %esi
1081     %esi = ADD32ri killed %esi, 15, implicit-def dead %eflags
1082     MOV32mr killed %rdi, 1, _, 0, _, killed %esi
1083     RETQ %eax
1085   bb.2.is_null:
1086     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
1087     RETQ %eax
1091 name:            inc_store_with_load_over_store
1092 # CHECK-LABEL: inc_store_with_load_over_store
1093 # CHECK: bb.0.entry:
1094 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
1095 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
1096 # CHECK: bb.1.not_null
1098 alignment:       4
1099 tracksRegLiveness: true
1100 liveins:
1101   - { reg: '%rdi' }
1102   - { reg: '%rsi' }
1103 body:             |
1104   bb.0.entry:
1105     liveins: %rdi, %rsi
1107     TEST64rr %rdi, %rdi, implicit-def %eflags
1108     JE_1 %bb.2.is_null, implicit killed %eflags
1110   bb.1.not_null:
1111     liveins: %rdi, %rsi
1113     MOV32mi killed %rsi, 1, _, 0, _, 2
1114     %eax = MOV32rm killed %rdi, 1, _, 0, _ 
1115     RETQ %eax
1117   bb.2.is_null:
1118     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
1119     RETQ %eax
1123 name:            inc_store_with_store_over_load
1124 # CHECK-LABEL: inc_store_with_store_over_load
1125 # CHECK: bb.0.entry:
1126 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
1127 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
1128 # CHECK: bb.1.not_null
1130 alignment:       4
1131 tracksRegLiveness: true
1132 liveins:
1133   - { reg: '%rdi' }
1134   - { reg: '%rsi' }
1135 body:             |
1136   bb.0.entry:
1137     liveins: %rdi, %rsi
1139     TEST64rr %rdi, %rdi, implicit-def %eflags
1140     JE_1 %bb.2.is_null, implicit killed %eflags
1142   bb.1.not_null:
1143     liveins: %rdi, %rsi
1145     %eax = MOV32rm killed %rsi, 1, _, 0, _ 
1146     MOV32mi killed %rdi, 1, _, 0, _, 2
1147     RETQ %eax
1149   bb.2.is_null:
1150     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
1151     RETQ %eax
1155 name:            inc_store_with_store_over_store
1156 # CHECK-LABEL: inc_store_with_store_over_store
1157 # CHECK: bb.0.entry:
1158 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
1159 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
1160 # CHECK: bb.1.not_null
1162 alignment:       4
1163 tracksRegLiveness: true
1164 liveins:
1165   - { reg: '%rdi' }
1166   - { reg: '%rsi' }
1167 body:             |
1168   bb.0.entry:
1169     liveins: %rdi, %rsi
1171     TEST64rr %rdi, %rdi, implicit-def %eflags
1172     JE_1 %bb.2.is_null, implicit killed %eflags
1174   bb.1.not_null:
1175     liveins: %rdi, %rsi
1177     MOV32mi killed %rsi, 1, _, 0, _, 3 
1178     MOV32mi killed %rdi, 1, _, 0, _, 2
1179     RETQ
1181   bb.2.is_null:
1182     RETQ
1186 name:            inc_store_with_load_and_store
1187 # CHECK-LABEL: inc_store_with_load_and_store
1188 # CHECK: bb.0.entry:
1189 # CHECK:  _ = FAULTING_OP 2, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 0, _, %esi, implicit-def %eflags
1190 # CHECK-NEXT: JMP_1 %bb.1.not_null
1191 # CHECK: bb.1.not_null
1193 alignment:       4
1194 tracksRegLiveness: true
1195 liveins:
1196   - { reg: '%rdi' }
1197   - { reg: '%rsi' }
1198 body:             |
1199   bb.0.entry:
1200     liveins: %rdi, %rsi
1202     TEST64rr %rdi, %rdi, implicit-def %eflags
1203     JE_1 %bb.2.is_null, implicit killed %eflags
1205   bb.1.not_null:
1206     liveins: %rdi, %rsi
1208     %esi = ADD32rr %esi, %esi, implicit-def dead %eflags
1209     ADD32mr killed %rdi, 1, _, 0, _, killed %esi, implicit-def dead %eflags
1210     RETQ
1212   bb.2.is_null:
1213     RETQ
1217 name:            inc_store_and_load_no_alias
1218 # CHECK-LABEL: inc_store_and_load_no_alias
1219 # CHECK: bb.0.entry:
1220 # CHECK:  %eax = FAULTING_OP 1, %bb.2.is_null, {{[0-9]+}}, %rdi, 1, _, 0, _ :: (load 4 from %ir.ptr)
1221 # CHECK-NEXT: JMP_1 %bb.1.not_null
1222 # CHECK: bb.1.not_null
1224 alignment:       4
1225 tracksRegLiveness: true
1226 liveins:
1227   - { reg: '%rdi' }
1228   - { reg: '%rsi' }
1229 body:             |
1230   bb.0.entry:
1231     liveins: %rdi, %rsi
1233     TEST64rr %rdi, %rdi, implicit-def %eflags
1234     JE_1 %bb.2.is_null, implicit killed %eflags
1236   bb.1.not_null:
1237     liveins: %rdi, %rsi
1239     MOV32mi killed %rsi, 1, _, 0, _, 3 :: (store 4 into %ir.ptr2)
1240     %eax = MOV32rm killed %rdi, 1, _, 0, _ :: (load 4 from %ir.ptr)
1241     RETQ %eax
1243   bb.2.is_null:
1244     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
1245     RETQ %eax
1249 name:            inc_store_and_load_alias
1250 # CHECK-LABEL: inc_store_and_load_alias
1251 # CHECK: bb.0.entry:
1252 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
1253 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
1254 # CHECK: bb.1.not_null
1256 alignment:       4
1257 tracksRegLiveness: true
1258 liveins:
1259   - { reg: '%rdi' }
1260   - { reg: '%rsi' }
1261 body:             |
1262   bb.0.entry:
1263     liveins: %rdi, %rsi
1265     TEST64rr %rdi, %rdi, implicit-def %eflags
1266     JE_1 %bb.2.is_null, implicit killed %eflags
1268   bb.1.not_null:
1269     liveins: %rdi, %rsi
1271     MOV32mi killed %rsi, 1, _, 0, _, 3 :: (store 4 into %ir.ptr2)
1272     %eax = MOV32rm killed %rdi, 1, _, 0, _ :: (load 4 from %ir.ptr)
1273     RETQ %eax
1275   bb.2.is_null:
1276     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
1277     RETQ %eax
1281 name:            inc_spill_dep
1282 # CHECK-LABEL: inc_spill_dep
1283 # CHECK: bb.0.entry:
1284 # CHECK:    TEST64rr %rdi, %rdi, implicit-def %eflags
1285 # CHECK-NEXT:    JE_1 %bb.2.is_null, implicit killed %eflags
1286 # CHECK: bb.1.not_null
1288 alignment:       4
1289 tracksRegLiveness: true
1290 stack:
1291   - { id: 0, type: spill-slot, offset: -8, size: 8, alignment: 8}
1292 liveins:
1293   - { reg: '%rdi' }
1294   - { reg: '%rsi' }
1295 body:             |
1296   bb.0.entry:
1297     liveins: %rdi, %rsi
1299     %rsp = frame-setup SUB64ri8 %rsp, 8, implicit-def dead %eflags
1300     MOV32mr %rsp, 1, %noreg, 0, %noreg, %esi :: (store 4 into %stack.0)
1301     TEST64rr %rdi, %rdi, implicit-def %eflags
1302     JE_1 %bb.2.is_null, implicit killed %eflags
1304   bb.1.not_null:
1305     liveins: %rdi, %rsi
1307     %r14d = MOV32rm %rsp, 1, %noreg, 0, %noreg :: (load 4 from %stack.0)
1308     MOV64mr %rsp, 1, %noreg, 0, %noreg, %rdi :: (store 8 into %stack.0)
1309     %edi = MOV32rm %rdi, 1, %noreg, 8, %noreg :: (load 4 from %ir.ptr)
1310     %eax = MOV32rr %edi
1311     RETQ %eax
1313   bb.2.is_null:
1314     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
1315     RETQ %eax