Skip to content

Commit de9b386

Browse files
committed
[X86] bypass-slow-division-64.ll - add optsize/minsize tests
Make sure we're not expanding div32-div64 codegen when we're focussed on codesize
1 parent 9833332 commit de9b386

File tree

1 file changed

+78
-4
lines changed

1 file changed

+78
-4
lines changed

llvm/test/CodeGen/X86/bypass-slow-division-64.ll

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,28 @@ define i64 @Test_get_quotient(i64 %a, i64 %b) nounwind {
5656
ret i64 %result
5757
}
5858

59+
define i64 @Test_get_quotient_optsize(i64 %a, i64 %b) nounwind optsize {
60+
; CHECK-LABEL: Test_get_quotient_optsize:
61+
; CHECK: # %bb.0:
62+
; CHECK-NEXT: movq %rdi, %rax
63+
; CHECK-NEXT: cqto
64+
; CHECK-NEXT: idivq %rsi
65+
; CHECK-NEXT: retq
66+
%result = sdiv i64 %a, %b
67+
ret i64 %result
68+
}
69+
70+
define i64 @Test_get_quotient_minsize(i64 %a, i64 %b) nounwind minsize {
71+
; CHECK-LABEL: Test_get_quotient_minsize:
72+
; CHECK: # %bb.0:
73+
; CHECK-NEXT: movq %rdi, %rax
74+
; CHECK-NEXT: cqto
75+
; CHECK-NEXT: idivq %rsi
76+
; CHECK-NEXT: retq
77+
%result = sdiv i64 %a, %b
78+
ret i64 %result
79+
}
80+
5981
define i64 @Test_get_remainder(i64 %a, i64 %b) nounwind {
6082
; FAST-DIVQ-LABEL: Test_get_remainder:
6183
; FAST-DIVQ: # %bb.0:
@@ -71,13 +93,13 @@ define i64 @Test_get_remainder(i64 %a, i64 %b) nounwind {
7193
; SLOW-DIVQ-NEXT: movq %rdi, %rcx
7294
; SLOW-DIVQ-NEXT: orq %rsi, %rcx
7395
; SLOW-DIVQ-NEXT: shrq $32, %rcx
74-
; SLOW-DIVQ-NEXT: je .LBB1_1
96+
; SLOW-DIVQ-NEXT: je .LBB3_1
7597
; SLOW-DIVQ-NEXT: # %bb.2:
7698
; SLOW-DIVQ-NEXT: cqto
7799
; SLOW-DIVQ-NEXT: idivq %rsi
78100
; SLOW-DIVQ-NEXT: movq %rdx, %rax
79101
; SLOW-DIVQ-NEXT: retq
80-
; SLOW-DIVQ-NEXT: .LBB1_1:
102+
; SLOW-DIVQ-NEXT: .LBB3_1:
81103
; SLOW-DIVQ-NEXT: # kill: def $eax killed $eax killed $rax
82104
; SLOW-DIVQ-NEXT: xorl %edx, %edx
83105
; SLOW-DIVQ-NEXT: divl %esi
@@ -87,6 +109,30 @@ define i64 @Test_get_remainder(i64 %a, i64 %b) nounwind {
87109
ret i64 %result
88110
}
89111

112+
define i64 @Test_get_remainder_optsize(i64 %a, i64 %b) nounwind optsize {
113+
; CHECK-LABEL: Test_get_remainder_optsize:
114+
; CHECK: # %bb.0:
115+
; CHECK-NEXT: movq %rdi, %rax
116+
; CHECK-NEXT: cqto
117+
; CHECK-NEXT: idivq %rsi
118+
; CHECK-NEXT: movq %rdx, %rax
119+
; CHECK-NEXT: retq
120+
%result = srem i64 %a, %b
121+
ret i64 %result
122+
}
123+
124+
define i64 @Test_get_remainder_minsize(i64 %a, i64 %b) nounwind minsize {
125+
; CHECK-LABEL: Test_get_remainder_minsize:
126+
; CHECK: # %bb.0:
127+
; CHECK-NEXT: movq %rdi, %rax
128+
; CHECK-NEXT: cqto
129+
; CHECK-NEXT: idivq %rsi
130+
; CHECK-NEXT: movq %rdx, %rax
131+
; CHECK-NEXT: retq
132+
%result = srem i64 %a, %b
133+
ret i64 %result
134+
}
135+
90136
define i64 @Test_get_quotient_and_remainder(i64 %a, i64 %b) nounwind {
91137
; FAST-DIVQ-LABEL: Test_get_quotient_and_remainder:
92138
; FAST-DIVQ: # %bb.0:
@@ -102,13 +148,13 @@ define i64 @Test_get_quotient_and_remainder(i64 %a, i64 %b) nounwind {
102148
; SLOW-DIVQ-NEXT: movq %rdi, %rcx
103149
; SLOW-DIVQ-NEXT: orq %rsi, %rcx
104150
; SLOW-DIVQ-NEXT: shrq $32, %rcx
105-
; SLOW-DIVQ-NEXT: je .LBB2_1
151+
; SLOW-DIVQ-NEXT: je .LBB6_1
106152
; SLOW-DIVQ-NEXT: # %bb.2:
107153
; SLOW-DIVQ-NEXT: cqto
108154
; SLOW-DIVQ-NEXT: idivq %rsi
109155
; SLOW-DIVQ-NEXT: addq %rdx, %rax
110156
; SLOW-DIVQ-NEXT: retq
111-
; SLOW-DIVQ-NEXT: .LBB2_1:
157+
; SLOW-DIVQ-NEXT: .LBB6_1:
112158
; SLOW-DIVQ-NEXT: # kill: def $eax killed $eax killed $rax
113159
; SLOW-DIVQ-NEXT: xorl %edx, %edx
114160
; SLOW-DIVQ-NEXT: divl %esi
@@ -122,6 +168,34 @@ define i64 @Test_get_quotient_and_remainder(i64 %a, i64 %b) nounwind {
122168
ret i64 %result
123169
}
124170

171+
define i64 @Test_get_quotient_and_remainder_optsize(i64 %a, i64 %b) nounwind optsize {
172+
; CHECK-LABEL: Test_get_quotient_and_remainder_optsize:
173+
; CHECK: # %bb.0:
174+
; CHECK-NEXT: movq %rdi, %rax
175+
; CHECK-NEXT: cqto
176+
; CHECK-NEXT: idivq %rsi
177+
; CHECK-NEXT: addq %rdx, %rax
178+
; CHECK-NEXT: retq
179+
%resultdiv = sdiv i64 %a, %b
180+
%resultrem = srem i64 %a, %b
181+
%result = add i64 %resultdiv, %resultrem
182+
ret i64 %result
183+
}
184+
185+
define i64 @Test_get_quotient_and_remainder_minsize(i64 %a, i64 %b) nounwind minsize {
186+
; CHECK-LABEL: Test_get_quotient_and_remainder_minsize:
187+
; CHECK: # %bb.0:
188+
; CHECK-NEXT: movq %rdi, %rax
189+
; CHECK-NEXT: cqto
190+
; CHECK-NEXT: idivq %rsi
191+
; CHECK-NEXT: addq %rdx, %rax
192+
; CHECK-NEXT: retq
193+
%resultdiv = sdiv i64 %a, %b
194+
%resultrem = srem i64 %a, %b
195+
%result = add i64 %resultdiv, %resultrem
196+
ret i64 %result
197+
}
198+
125199
define void @PR43514(i32 %x, i32 %y) {
126200
; CHECK-LABEL: PR43514:
127201
; CHECK: # %bb.0:

0 commit comments

Comments
 (0)