llvm.org GIT mirror llvm / b98f609
[X86] Add test cases showing missed opportunities to use the C flag from the BLSI instruction to avoid a TEST instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363909 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 2 months ago
1 changed file(s) with 65 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
12221222
12231223 ret void
12241224 }
1225
1226 define i32 @blsi_cflag_32(i32 %x, i32 %y) nounwind {
1227 ; X86-LABEL: blsi_cflag_32:
1228 ; X86: # %bb.0:
1229 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1230 ; X86-NEXT: testl %eax, %eax
1231 ; X86-NEXT: jne .LBB50_1
1232 ; X86-NEXT: # %bb.2:
1233 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1234 ; X86-NEXT: retl
1235 ; X86-NEXT: .LBB50_1:
1236 ; X86-NEXT: blsil %eax, %eax
1237 ; X86-NEXT: retl
1238 ;
1239 ; X64-LABEL: blsi_cflag_32:
1240 ; X64: # %bb.0:
1241 ; X64-NEXT: blsil %edi, %eax
1242 ; X64-NEXT: testl %edi, %edi
1243 ; X64-NEXT: cmovel %esi, %eax
1244 ; X64-NEXT: retq
1245 %tobool = icmp eq i32 %x, 0
1246 %sub = sub nsw i32 0, %x
1247 %and = and i32 %sub, %x
1248 %cond = select i1 %tobool, i32 %y, i32 %and
1249 ret i32 %cond
1250 }
1251
1252 define i64 @blsi_cflag_64(i64 %x, i64 %y) nounwind {
1253 ; X86-LABEL: blsi_cflag_64:
1254 ; X86: # %bb.0:
1255 ; X86-NEXT: pushl %edi
1256 ; X86-NEXT: pushl %esi
1257 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1258 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1259 ; X86-NEXT: xorl %edx, %edx
1260 ; X86-NEXT: movl %ecx, %eax
1261 ; X86-NEXT: negl %eax
1262 ; X86-NEXT: sbbl %esi, %edx
1263 ; X86-NEXT: movl %ecx, %edi
1264 ; X86-NEXT: orl %esi, %edi
1265 ; X86-NEXT: jne .LBB51_1
1266 ; X86-NEXT: # %bb.2:
1267 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1268 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1269 ; X86-NEXT: jmp .LBB51_3
1270 ; X86-NEXT: .LBB51_1:
1271 ; X86-NEXT: andl %esi, %edx
1272 ; X86-NEXT: andl %ecx, %eax
1273 ; X86-NEXT: .LBB51_3:
1274 ; X86-NEXT: popl %esi
1275 ; X86-NEXT: popl %edi
1276 ; X86-NEXT: retl
1277 ;
1278 ; X64-LABEL: blsi_cflag_64:
1279 ; X64: # %bb.0:
1280 ; X64-NEXT: blsiq %rdi, %rax
1281 ; X64-NEXT: testq %rdi, %rdi
1282 ; X64-NEXT: cmoveq %rsi, %rax
1283 ; X64-NEXT: retq
1284 %tobool = icmp eq i64 %x, 0
1285 %sub = sub nsw i64 0, %x
1286 %and = and i64 %sub, %x
1287 %cond = select i1 %tobool, i64 %y, i64 %and
1288 ret i64 %cond
1289 }