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 EAX<imp-def> 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 EAX<imp-use> 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 # CHECK-LABEL: name: test1
34 exposesReturnsTwice: false
36 regBankSelected: false
38 tracksRegLiveness: true
47 # Verify that "movw (%rax), %ax" is changed to "movzwl (%rax), %rax".
49 # For that to happen, the liveness information after the MOV16rm
50 # instruction should be used, not before it because %rax is live
51 # before the MOV and is killed by it.
56 %ax = MOV16rm killed %rax, 1, _, 0, _
57 ; CHECK: %eax = MOVZX32rm16 killed %rax
63 # CHECK-LABEL: name: test2
66 exposesReturnsTwice: false
68 regBankSelected: false
70 tracksRegLiveness: true
79 # Imp-use of any super-register means the register is live before the MOV
82 liveins: %dl, %rbx, %rcx, %r14
84 %cl = MOV8rr killed %dl, implicit killed %rcx, implicit-def %rcx
85 ; CHECK: %cl = MOV8rr killed %dl, implicit killed %rcx, implicit-def %rcx
94 # CHECK-LABEL: name: test3
97 exposesReturnsTwice: false
99 regBankSelected: false
101 tracksRegLiveness: true
104 - { reg: '%rdi', virtual-reg: '' }
106 isFrameAddressTaken: false
107 isReturnAddressTaken: false
117 hasOpaqueSPAdjustment: false
119 hasMustTailInVarArgFunc: false
125 # After MOV16rm the whole %eax is not *really* live, as can be seen by
126 # missing implicit-uses of it in that MOV. Make sure that MOV is
127 # transformed into MOVZX.
128 # See the comment near the original IR on what preceding decisions can
132 successors: %bb.1(0x30000000), %bb.2.if.then(0x50000000)
135 TEST64rr %rdi, %rdi, implicit-def %eflags
136 JE_1 %bb.1, implicit %eflags
141 %ax = MOV16rm killed %rdi, 1, _, 0, _, implicit-def %eax :: (load 2 from %ir.p)
142 ; CHECK: %eax = MOVZX32rm16 killed %rdi, 1, _, 0, _, implicit-def %eax :: (load 2 from %ir.p)
143 %ax = KILL %ax, implicit killed %eax
147 %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
148 %ax = KILL %ax, implicit killed %eax