Commit fe61dd0
committed
[DAG] Fold mismatched widened avg idioms to narrow form (#147946)
This fold corrects mismatched widened averaging idioms by folding:
`trunc(avgceilu(sext(x), sext(y))) -> avgceils(x, y)`
`trunc(avgceils(zext(x), zext(y))) -> avgceilu(x, y)`
When inputs are sign-extended, unsigned and signed averaging operations produce identical results after truncation, allowing us to use the semantically correct narrow operation.
alive2: https://alive2.llvm.org/ce/z/ZRbfHT1 parent 53ddeb4 commit fe61dd0
File tree
2 files changed
+107
-3
lines changed- llvm
- lib/CodeGen/SelectionDAG
- test/CodeGen/AArch64
2 files changed
+107
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16482 | 16482 | | |
16483 | 16483 | | |
16484 | 16484 | | |
16485 | | - | |
16486 | | - | |
16487 | | - | |
16488 | 16485 | | |
| 16486 | + | |
| 16487 | + | |
| 16488 | + | |
| 16489 | + | |
| 16490 | + | |
| 16491 | + | |
| 16492 | + | |
| 16493 | + | |
| 16494 | + | |
| 16495 | + | |
| 16496 | + | |
| 16497 | + | |
| 16498 | + | |
| 16499 | + | |
| 16500 | + | |
| 16501 | + | |
| 16502 | + | |
| 16503 | + | |
| 16504 | + | |
| 16505 | + | |
| 16506 | + | |
| 16507 | + | |
| 16508 | + | |
| 16509 | + | |
| 16510 | + | |
16489 | 16511 | | |
16490 | 16512 | | |
16491 | 16513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1408 | 1408 | | |
1409 | 1409 | | |
1410 | 1410 | | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
1411 | 1493 | | |
1412 | 1494 | | |
1413 | 1495 | | |
| |||
0 commit comments