pr9517.ll
5.21 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
136
137
138
139
140
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -o - %s -mtriple=x86_64--unknown-linux-gnu | FileCheck %s
@base = external dso_local local_unnamed_addr global i16, align 2
; We should be able to merge the two loads here
define i16 @unify_through_trivial_asm() {
; CHECK-LABEL: unify_through_trivial_asm:
; CHECK: # %bb.0:
; CHECK-NEXT: movzwl {{.*}}(%rip), %eax
; CHECK-NEXT: #APP
; CHECK-NEXT: nop
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %eax
; CHECK-NEXT: incl %eax
; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-NEXT: retq
%x = load i16, i16* @base, align 2
tail call void asm sideeffect "nop", "r,~{dirflag},~{fpsr},~{flags}"(i16 %x)
%x2 = load i16, i16* @base, align 2
%v = add i16 %x2, 1
ret i16 %v
}
; The asm call prevents the merging the loads here.
define i16 @unify_through_trival_asm_w_memory_clobber() {
; CHECK-LABEL: unify_through_trival_asm_w_memory_clobber:
; CHECK: # %bb.0:
; CHECK-NEXT: movzwl {{.*}}(%rip), %eax
; CHECK-NEXT: #APP
; CHECK-NEXT: nop
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %eax
; CHECK-NEXT: incl %eax
; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
; CHECK-NEXT: retq
%x = load i16, i16* @base, align 2
tail call void asm sideeffect "nop", "+r,~{dirflag},~{fpsr},~{flags},~{base},~{memory}"(i16 %x)
%x2 = load i16, i16* @base, align 2
%v = add i16 %x2, 1
ret i16 %v
}
define dso_local void @fulltest() local_unnamed_addr {
; CHECK-LABEL: fulltest:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $1, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $2, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $3, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $4, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $5, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $6, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $7, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: movzwl {{.*}}(%rip), %edx
; CHECK-NEXT: addl $16, %edx
; CHECK-NEXT: movb $8, %al
; CHECK-NEXT: # kill: def $dx killed $dx killed $edx
; CHECK-NEXT: #APP
; CHECK-NEXT: outb %al, %dx
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: retq
entry:
%0 = load i16, i16* @base, align 2
%add = add i16 %0, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 0, i16 %add)
%1 = load i16, i16* @base, align 2
%add3 = add i16 %1, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 1, i16 %add3)
%2 = load i16, i16* @base, align 2
%add6 = add i16 %2, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 2, i16 %add6)
%3 = load i16, i16* @base, align 2
%add9 = add i16 %3, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 3, i16 %add9)
%4 = load i16, i16* @base, align 2
%add12 = add i16 %4, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 4, i16 %add12)
%5 = load i16, i16* @base, align 2
%add15 = add i16 %5, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 5, i16 %add15)
%6 = load i16, i16* @base, align 2
%add18 = add i16 %6, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 6, i16 %add18)
%7 = load i16, i16* @base, align 2
%add21 = add i16 %7, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 7, i16 %add21)
%8 = load i16, i16* @base, align 2
%add24 = add i16 %8, 16
tail call void asm sideeffect "outb %al,${1:w}", "{ax},{dx},~{dirflag},~{fpsr},~{flags}"(i8 8, i16 %add24)
ret void
}