llvm.org GIT mirror llvm / 8dcd98d
[X86] Add test cases to show where LowerSELECT doesn't select SADDO/SSUBO to INC/DEC, but LowerXALUOOp does. Leading to duplicate code. When SADDO/SSUBO is used as a part of a condition, the X86 backend has to lower the instruction twice. One for the flags use and then once for the data use. These two selections should be kept in sync so they end up with one node providing the data and the flags. This doesn't seem to be happening for INC/DEC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350194 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 9 months ago
1 changed file(s) with 79 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
14041404 ret {i64, i1} %t
14051405 }
14061406
1407 ; FIXME: We're selecting both an INC and an ADD here. One of them becomes an LEA.
1408 define i32 @incovfselectstore(i32 %v1, i32 %v2, i32* %x) {
1409 ; SDAG-LABEL: incovfselectstore:
1410 ; SDAG: ## %bb.0:
1411 ; SDAG-NEXT: movl %esi, %eax
1412 ; SDAG-NEXT: ## kill: def $edi killed $edi def $rdi
1413 ; SDAG-NEXT: leal 1(%rdi), %ecx
1414 ; SDAG-NEXT: movl %edi, %esi
1415 ; SDAG-NEXT: addl $1, %esi
1416 ; SDAG-NEXT: cmovol %edi, %eax
1417 ; SDAG-NEXT: movl %ecx, (%rdx)
1418 ; SDAG-NEXT: retq
1419 ;
1420 ; FAST-LABEL: incovfselectstore:
1421 ; FAST: ## %bb.0:
1422 ; FAST-NEXT: movl %esi, %eax
1423 ; FAST-NEXT: movl %edi, %ecx
1424 ; FAST-NEXT: incl %ecx
1425 ; FAST-NEXT: cmovol %edi, %eax
1426 ; FAST-NEXT: movl %ecx, (%rdx)
1427 ; FAST-NEXT: retq
1428 ;
1429 ; KNL-LABEL: incovfselectstore:
1430 ; KNL: ## %bb.0:
1431 ; KNL-NEXT: movl %esi, %eax
1432 ; KNL-NEXT: ## kill: def $edi killed $edi def $rdi
1433 ; KNL-NEXT: leal 1(%rdi), %ecx
1434 ; KNL-NEXT: movl %edi, %esi
1435 ; KNL-NEXT: addl $1, %esi
1436 ; KNL-NEXT: cmovol %edi, %eax
1437 ; KNL-NEXT: movl %ecx, (%rdx)
1438 ; KNL-NEXT: retq
1439 %t = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %v1, i32 1)
1440 %obit = extractvalue {i32, i1} %t, 1
1441 %ret = select i1 %obit, i32 %v1, i32 %v2
1442 %val = extractvalue {i32, i1} %t, 0
1443 store i32 %val, i32* %x
1444 ret i32 %ret
1445 }
1446
1447 ; FIXME: We're selecting both a DEC and a SUB here. DEC becomes an LEA and
1448 ; SUB becomes a CMP.
1449 define i32 @decovfselectstore(i32 %v1, i32 %v2, i32* %x) {
1450 ; SDAG-LABEL: decovfselectstore:
1451 ; SDAG: ## %bb.0:
1452 ; SDAG-NEXT: movl %esi, %eax
1453 ; SDAG-NEXT: ## kill: def $edi killed $edi def $rdi
1454 ; SDAG-NEXT: leal -1(%rdi), %ecx
1455 ; SDAG-NEXT: cmpl $1, %edi
1456 ; SDAG-NEXT: cmovol %edi, %eax
1457 ; SDAG-NEXT: movl %ecx, (%rdx)
1458 ; SDAG-NEXT: retq
1459 ;
1460 ; FAST-LABEL: decovfselectstore:
1461 ; FAST: ## %bb.0:
1462 ; FAST-NEXT: movl %esi, %eax
1463 ; FAST-NEXT: movl %edi, %ecx
1464 ; FAST-NEXT: decl %ecx
1465 ; FAST-NEXT: cmovol %edi, %eax
1466 ; FAST-NEXT: movl %ecx, (%rdx)
1467 ; FAST-NEXT: retq
1468 ;
1469 ; KNL-LABEL: decovfselectstore:
1470 ; KNL: ## %bb.0:
1471 ; KNL-NEXT: movl %esi, %eax
1472 ; KNL-NEXT: ## kill: def $edi killed $edi def $rdi
1473 ; KNL-NEXT: leal -1(%rdi), %ecx
1474 ; KNL-NEXT: cmpl $1, %edi
1475 ; KNL-NEXT: cmovol %edi, %eax
1476 ; KNL-NEXT: movl %ecx, (%rdx)
1477 ; KNL-NEXT: retq
1478 %t = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %v1, i32 1)
1479 %obit = extractvalue {i32, i1} %t, 1
1480 %ret = select i1 %obit, i32 %v1, i32 %v2
1481 %val = extractvalue {i32, i1} %t, 0
1482 store i32 %val, i32* %x
1483 ret i32 %ret
1484 }
1485
14071486 declare {i8, i1} @llvm.sadd.with.overflow.i8 (i8, i8 ) nounwind readnone
14081487 declare {i16, i1} @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
14091488 declare {i32, i1} @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone