branchfolding-debug-invariant.mir
3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# RUN: llc -mtriple=x86_64-- -run-pass branch-folder -O3 -o - %s | FileCheck %s
---
name: test1a
body: |
; CHECK-LABEL: name: test1a
; CHECK: bb.0:
; CHECK: TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
; CHECK: JCC_1 %bb.2, 5, implicit $eflags
; CHECK: bb.1:
; CHECK: successors: %bb.2(0x80000000)
; CHECK: MOV8mi $r12, 1, $noreg, 0, $noreg, 0
; CHECK-NOT: RET
; CHECK: bb.2:
; CHECK: MOV8mi $r13, 1, $noreg, 0, $noreg, 0
; CHECK: RET 0
bb.0:
TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
JCC_1 %bb.2, 5, implicit killed $eflags
bb.1:
MOV8mi $r12, 1, $noreg, 0, $noreg, 0
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
bb.2:
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
...
---
name: test1b
body: |
; Verify that we get the same rewrites as in test1a when adding some
; DBG_VALUE instructions in the mix.
;
; CHECK-LABEL: name: test1b
; CHECK: bb.0:
; CHECK: TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
; CHECK: JCC_1 %bb.2, 5, implicit $eflags
; CHECK: bb.1:
; CHECK: successors: %bb.2(0x80000000)
; CHECK: MOV8mi $r12, 1, $noreg, 0, $noreg, 0
; CHECK-NOT: RET
; CHECK: bb.2:
; CHECK: DBG_VALUE
; CHECK: DBG_VALUE
; CHECK: MOV8mi $r13, 1, $noreg, 0, $noreg, 0
; CHECK: RET 0
bb.0:
TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
JCC_1 %bb.2, 5, implicit killed $eflags
bb.1:
MOV8mi $r12, 1, $noreg, 0, $noreg, 0
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
bb.2:
DBG_VALUE
DBG_VALUE
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
...
---
name: test2a
body: |
; CFI instruction currently prevents the rewrite here (although technically
; I suppose that branch folding could let bb.1 fallthrough into bb.2 here).
;
; CHECK-LABEL: name: test2a
; CHECK: bb.0:
; CHECK: TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
; CHECK: JCC_1 %bb.2, 5, implicit killed $eflags
; CHECK: bb.1:
; CHECK: MOV8mi $r12, 1, $noreg, 0, $noreg, 0
; CHECK: MOV8mi $r13, 1, $noreg, 0, $noreg, 0
; CHECK: RET 0
; CHECK: bb.2:
; CHECK: CFI_INSTRUCTION def_cfa_offset 8
; CHECK: MOV8mi $r13, 1, $noreg, 0, $noreg, 0
; CHECK: RET 0
bb.0:
TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
JCC_1 %bb.2, 5, implicit killed $eflags
bb.1:
MOV8mi $r12, 1, $noreg, 0, $noreg, 0
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
bb.2:
CFI_INSTRUCTION def_cfa_offset 8
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
...
---
name: test2b
body: |
; Verify that we get the same rewrites as in test1a when adding some
; DBG_VALUE instructions in the mix.
;
; CHECK-LABEL: name: test2b
; CHECK: bb.0:
; CHECK: TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
; CHECK: JCC_1 %bb.2, 5, implicit killed $eflags
; CHECK: bb.1:
; CHECK: MOV8mi $r12, 1, $noreg, 0, $noreg, 0
; CHECK: MOV8mi $r13, 1, $noreg, 0, $noreg, 0
; CHECK: RET 0
; CHECK: bb.2:
; CHECK: DBG_VALUE
; CHECK: CFI_INSTRUCTION def_cfa_offset 8
; CHECK: DBG_VALUE
; CHECK: MOV8mi $r13, 1, $noreg, 0, $noreg, 0
; CHECK: RET 0
bb.0:
TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
JCC_1 %bb.2, 5, implicit killed $eflags
bb.1:
MOV8mi $r12, 1, $noreg, 0, $noreg, 0
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
bb.2:
DBG_VALUE
CFI_INSTRUCTION def_cfa_offset 8
DBG_VALUE
MOV8mi $r13, 1, $noreg, 0, $noreg, 0
RET 0
...