[PowerPC] Recommit r314244 with refactoring and off by default
[llvm-core.git] / test / CodeGen / X86 / fixup-bw-inst.mir
blob77d13bd06519813c671a237ee552f70b7a030908
1 # RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass x86-fixup-bw-insts %s -o - | FileCheck  %s
3 --- |
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.
10   ;
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).
16   entry:
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
22     br label %if.end
24   if.end:                                           ; preds = %if.then, %entry
25     %i.0 = phi i16 [ %0, %if.then ], [ 0, %entry ]
26     ret i16 %i.0
27   }
29 ...
30 ---
31 # CHECK-LABEL: name: test1
32 name:            test1
33 alignment:       4
34 exposesReturnsTwice: false
35 legalized:       false
36 regBankSelected: false
37 selected:        false
38 tracksRegLiveness: true
39 registers:
40 liveins:
41   - { reg: '%rax' }
42 frameInfo:
43   stackSize:       0
44 fixedStack:
45 stack:
46 constants:
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.
52 body:             |
53   bb.0:
54     liveins: %rax
56     %ax = MOV16rm killed %rax, 1, _, 0, _
57     ; CHECK: %eax = MOVZX32rm16 killed %rax
59     RETQ %ax
61 ...
62 ---
63 # CHECK-LABEL: name: test2
64 name:            test2
65 alignment:       4
66 exposesReturnsTwice: false
67 legalized:       false
68 regBankSelected: false
69 selected:        false
70 tracksRegLiveness: true
71 registers:
72 liveins:
73   - { reg: '%rax' }
74 frameInfo:
75   stackSize:       0
76 fixedStack:
77 stack:
78 constants:
79 # Imp-use of any super-register means the register is live before the MOV
80 body:             |
81   bb.0:
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
86     JMP_1 %bb.1
87   bb.1:
88     liveins: %rcx
90     RETQ %cl
92 ...
93 ---
94 # CHECK-LABEL: name: test3
95 name:            test3
96 alignment:       4
97 exposesReturnsTwice: false
98 legalized:       false
99 regBankSelected: false
100 selected:        false
101 tracksRegLiveness: true
102 registers:
103 liveins:
104   - { reg: '%rdi', virtual-reg: '' }
105 frameInfo:
106   isFrameAddressTaken: false
107   isReturnAddressTaken: false
108   hasStackMap:     false
109   hasPatchPoint:   false
110   stackSize:       0
111   offsetAdjustment: 0
112   maxAlignment:    0
113   adjustsStack:    false
114   hasCalls:        false
115   stackProtector:  ''
116   maxCallFrameSize: 0
117   hasOpaqueSPAdjustment: false
118   hasVAStart:      false
119   hasMustTailInVarArgFunc: false
120   savePoint:       ''
121   restorePoint:    ''
122 fixedStack:
123 stack:
124 constants:
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
129 # lead to that.
130 body:             |
131   bb.0.entry:
132     successors: %bb.1(0x30000000), %bb.2.if.then(0x50000000)
133     liveins: %rdi
135     TEST64rr %rdi, %rdi, implicit-def %eflags
136     JE_1 %bb.1, implicit %eflags
138   bb.2.if.then:
139     liveins: %rdi
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
144     RETQ %ax
146   bb.1:
147     %eax = XOR32rr undef %eax, undef %eax, implicit-def dead %eflags
148     %ax = KILL %ax, implicit killed %eax
149     RETQ %ax