1 # RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass x86-fixup-bw-insts %s -o - | FileCheck %s
4 define void @test1() { ret void }
5 define void @test2() { ret void }
7 define i16 @test3(i16* readonly %p) {
8 ; Keep original IR to show how the situation like this might happen
9 ; due to preceding CG passes.
11 ; %0 is used in %if.end BB (before tail-duplication), so its
12 ; corresponding super-register (EAX) is live-in into that BB (%if.end)
13 ; and also has an implicit-def EAX flag. Make sure that we still change
14 ; the movw into movzwl because EAX is not live before the load (which
15 ; can be seen by the fact that implicit EAX flag is missing).
17 %tobool = icmp eq i16* %p, null
18 br i1 %tobool, label %if.end, label %if.then
20 if.then: ; preds = %entry
21 %0 = load i16, i16* %p, align 2
24 if.end: ; preds = %if.then, %entry
25 %i.0 = phi i16 [ %0, %if.then ], [ 0, %entry ]
31 %t1 = zext i1 undef to i16
32 %t2 = or i16 undef, %t1
36 define void @test5() {ret void}
40 # CHECK-LABEL: name: test1
43 tracksRegLiveness: true
46 # Verify that "movw ($rax), $ax" is changed to "movzwl ($rax), $rax".
48 # For that to happen, the liveness information after the MOV16rm
49 # instruction should be used, not before it because $rax is live
50 # before the MOV and is killed by it.
55 $ax = MOV16rm killed $rax, 1, $noreg, 0, $noreg
56 ; CHECK: $eax = MOVZX32rm16 killed $rax
62 # CHECK-LABEL: name: test2
65 tracksRegLiveness: true
68 # Imp-use of any super-register means the register is live before the MOV
71 liveins: $dl, $rbx, $rcx, $r14
73 $cl = MOV8rr killed $dl, implicit killed $rcx, implicit-def $rcx
74 ; CHECK: $cl = MOV8rr killed $dl, implicit killed $rcx, implicit-def $rcx
83 # CHECK-LABEL: name: test3
86 tracksRegLiveness: true
89 # After MOV16rm the whole $eax is not *really* live, as can be seen by
90 # missing implicit-uses of it in that MOV. Make sure that MOV is
91 # transformed into MOVZX.
92 # See the comment near the original IR on what preceding decisions can
96 successors: %bb.1(0x30000000), %bb.2.if.then(0x50000000)
99 TEST64rr $rdi, $rdi, implicit-def $eflags
100 JCC_1 %bb.1, 4, implicit $eflags
105 $ax = MOV16rm killed $rdi, 1, $noreg, 0, $noreg, implicit-def $eax :: (load 2 from %ir.p)
106 ; CHECK: $eax = MOVZX32rm16 killed $rdi, 1, $noreg, 0, $noreg, implicit-def $eax :: (load 2 from %ir.p)
107 $ax = KILL $ax, implicit killed $eax
111 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
112 $ax = KILL $ax, implicit killed $eax
117 # CHECK-LABEL: name: test4
120 tracksRegLiveness: true
123 # This code copies r10b into r9b and then uses r9w. We would like to promote
124 # the copy to a 32-bit copy, but because r9w is used this is not acceptable.
129 $r9b = MOV8rr undef $r10b, implicit-def $r9d, implicit killed $r9d, implicit-def $eflags
130 ; CHECK: $r9b = MOV8rr undef $r10b, implicit-def $r9d, implicit killed $r9d, implicit-def $eflags
132 $ax = OR16rr undef $ax, $r9w, implicit-def $eflags
137 # CHECK-LABEL: name: test5
140 tracksRegLiveness: true
142 - { reg: '$ch', reg: '$bl' }
147 $cl = MOV8rr $bl, implicit-def $cx, implicit killed $ch, implicit-def $eflags
148 ; CHECK: $cl = MOV8rr $bl, implicit-def $cx, implicit killed $ch, implicit-def $eflags