@@ -1305,6 +1305,200 @@ def match_addos : GICombineRule<
1305
1305
[{ return Helper.matchAddOverflow(*${root}, ${matchinfo}); }]),
1306
1306
(apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>;
1307
1307
1308
+ def match_extract_of_element_undef_vector: GICombineRule <
1309
+ (defs root:$root),
1310
+ (match (G_IMPLICIT_DEF $vector),
1311
+ (G_EXTRACT_VECTOR_ELT $root, $vector, $idx)),
1312
+ (apply (G_IMPLICIT_DEF $root))
1313
+ >;
1314
+
1315
+ def match_extract_of_element_undef_index: GICombineRule <
1316
+ (defs root:$root),
1317
+ (match (G_IMPLICIT_DEF $idx),
1318
+ (G_EXTRACT_VECTOR_ELT $root, $vector, $idx)),
1319
+ (apply (G_IMPLICIT_DEF $root))
1320
+ >;
1321
+
1322
+ def match_extract_of_element : GICombineRule<
1323
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1324
+ (match (wip_match_opcode G_EXTRACT_VECTOR_ELT):$root,
1325
+ [{ return Helper.matchExtractVectorElement(*${root}, ${matchinfo}); }]),
1326
+ (apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>;
1327
+
1328
+ def extract_vector_element_not_const : GICombineRule<
1329
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1330
+ (match (G_INSERT_VECTOR_ELT $src, $x, $value, $idx),
1331
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx)),
1332
+ (apply (GIReplaceReg $root, $value))>;
1333
+
1334
+ def extract_vector_element_different_indices : GICombineRule<
1335
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1336
+ (match (G_INSERT_VECTOR_ELT $src, $x, $value, $idx2),
1337
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx1),
1338
+ [{ return Helper.matchExtractVectorElementWithDifferentIndices(${root}, ${matchinfo}); }]),
1339
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1340
+
1341
+ def extract_vector_element_build_vector2 : GICombineRule<
1342
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1343
+ (match (G_BUILD_VECTOR $src, $x, $y),
1344
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1345
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1346
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1347
+
1348
+ def extract_vector_element_build_vector3 : GICombineRule<
1349
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1350
+ (match (G_BUILD_VECTOR $src, $x, $y, $z),
1351
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1352
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1353
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1354
+
1355
+ def extract_vector_element_build_vector4 : GICombineRule<
1356
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1357
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a),
1358
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1359
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1360
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1361
+
1362
+ def extract_vector_element_build_vector5 : GICombineRule<
1363
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1364
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b),
1365
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1366
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1367
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1368
+
1369
+ def extract_vector_element_build_vector6 : GICombineRule<
1370
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1371
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c),
1372
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1373
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1374
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1375
+
1376
+ def extract_vector_element_build_vector7 : GICombineRule<
1377
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1378
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d),
1379
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1380
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1381
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1382
+
1383
+ def extract_vector_element_build_vector8 : GICombineRule<
1384
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1385
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e),
1386
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1387
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1388
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1389
+
1390
+ def extract_vector_element_build_vector9 : GICombineRule<
1391
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1392
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f),
1393
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1394
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1395
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1396
+
1397
+ def extract_vector_element_build_vector10 : GICombineRule<
1398
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1399
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f, $g),
1400
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1401
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1402
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1403
+
1404
+ def extract_vector_element_build_vector11 : GICombineRule<
1405
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1406
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f, $g, $h),
1407
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1408
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1409
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1410
+
1411
+ def extract_vector_element_build_vector12 : GICombineRule<
1412
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1413
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f, $g, $h, $i),
1414
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1415
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1416
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1417
+
1418
+ def extract_vector_element_build_vector13 : GICombineRule<
1419
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1420
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j),
1421
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1422
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1423
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1424
+
1425
+ def extract_vector_element_build_vector14 : GICombineRule<
1426
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1427
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k),
1428
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1429
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1430
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1431
+
1432
+ def extract_vector_element_build_vector15 : GICombineRule<
1433
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1434
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l),
1435
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1436
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1437
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1438
+
1439
+ def extract_vector_element_build_vector16 : GICombineRule<
1440
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1441
+ (match (G_BUILD_VECTOR $src, $x, $y, $z, $a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l, $m),
1442
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1443
+ [{ return Helper.matchExtractVectorElementWithBuildVector(${root}, ${matchinfo}); }]),
1444
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1445
+
1446
+ def extract_vector_element_build_vector_trunc2 : GICombineRule<
1447
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1448
+ (match (G_BUILD_VECTOR_TRUNC $src, $x, $y),
1449
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1450
+ [{ return Helper.matchExtractVectorElementWithBuildVectorTrunc(${root}, ${matchinfo}); }]),
1451
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1452
+
1453
+ def extract_vector_element_build_vector_trunc3 : GICombineRule<
1454
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1455
+ (match (G_BUILD_VECTOR_TRUNC $src, $x, $y, $z),
1456
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1457
+ [{ return Helper.matchExtractVectorElementWithBuildVectorTrunc(${root}, ${matchinfo}); }]),
1458
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1459
+
1460
+ def extract_vector_element_build_vector_trunc4 : GICombineRule<
1461
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1462
+ (match (G_BUILD_VECTOR_TRUNC $src, $x, $y, $z, $a),
1463
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1464
+ [{ return Helper.matchExtractVectorElementWithBuildVectorTrunc(${root}, ${matchinfo}); }]),
1465
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1466
+
1467
+ def extract_vector_element_build_vector_trunc5 : GICombineRule<
1468
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1469
+ (match (G_BUILD_VECTOR_TRUNC $src, $x, $y, $z, $a, $b),
1470
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1471
+ [{ return Helper.matchExtractVectorElementWithBuildVectorTrunc(${root}, ${matchinfo}); }]),
1472
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1473
+
1474
+ def extract_vector_element_build_vector_trunc6 : GICombineRule<
1475
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1476
+ (match (G_BUILD_VECTOR_TRUNC $src, $x, $y, $z, $a, $b, $c),
1477
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1478
+ [{ return Helper.matchExtractVectorElementWithBuildVectorTrunc(${root}, ${matchinfo}); }]),
1479
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1480
+
1481
+ def extract_vector_element_build_vector_trunc7 : GICombineRule<
1482
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1483
+ (match (G_BUILD_VECTOR_TRUNC $src, $x, $y, $z, $a, $b, $c, $d),
1484
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1485
+ [{ return Helper.matchExtractVectorElementWithBuildVectorTrunc(${root}, ${matchinfo}); }]),
1486
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1487
+
1488
+ def extract_vector_element_build_vector_trunc8 : GICombineRule<
1489
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1490
+ (match (G_BUILD_VECTOR_TRUNC $src, $x, $y, $z, $a, $b, $c, $d, $e),
1491
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1492
+ [{ return Helper.matchExtractVectorElementWithBuildVectorTrunc(${root}, ${matchinfo}); }]),
1493
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1494
+
1495
+ def extract_vector_element_freeze : GICombineRule<
1496
+ (defs root:$root, build_fn_matchinfo:$matchinfo),
1497
+ (match (G_FREEZE $src, $input),
1498
+ (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
1499
+ [{ return Helper.matchExtractVectorElementWithFreeze(${root}, ${matchinfo}); }]),
1500
+ (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
1501
+
1308
1502
// Combines concat operations
1309
1503
def concat_matchinfo : GIDefMatchData<"SmallVector<Register>">;
1310
1504
def combine_concat_vector : GICombineRule<
@@ -1313,6 +1507,37 @@ def combine_concat_vector : GICombineRule<
1313
1507
[{ return Helper.matchCombineConcatVectors(*${root}, ${matchinfo}); }]),
1314
1508
(apply [{ Helper.applyCombineConcatVectors(*${root}, ${matchinfo}); }])>;
1315
1509
1510
+ // match_extract_of_element must be the first!
1511
+ def vector_ops_combines: GICombineGroup<[
1512
+ match_extract_of_element_undef_vector,
1513
+ match_extract_of_element_undef_index,
1514
+ match_extract_of_element,
1515
+ extract_vector_element_not_const,
1516
+ extract_vector_element_different_indices,
1517
+ extract_vector_element_build_vector2,
1518
+ extract_vector_element_build_vector3,
1519
+ extract_vector_element_build_vector4,
1520
+ extract_vector_element_build_vector5,
1521
+ extract_vector_element_build_vector7,
1522
+ extract_vector_element_build_vector8,
1523
+ extract_vector_element_build_vector9,
1524
+ extract_vector_element_build_vector10,
1525
+ extract_vector_element_build_vector11,
1526
+ extract_vector_element_build_vector12,
1527
+ extract_vector_element_build_vector13,
1528
+ extract_vector_element_build_vector14,
1529
+ extract_vector_element_build_vector15,
1530
+ extract_vector_element_build_vector16,
1531
+ extract_vector_element_build_vector_trunc2,
1532
+ extract_vector_element_build_vector_trunc3,
1533
+ extract_vector_element_build_vector_trunc4,
1534
+ extract_vector_element_build_vector_trunc5,
1535
+ extract_vector_element_build_vector_trunc6,
1536
+ extract_vector_element_build_vector_trunc7,
1537
+ extract_vector_element_build_vector_trunc8,
1538
+ extract_vector_element_freeze
1539
+ ]>;
1540
+
1316
1541
// FIXME: These should use the custom predicate feature once it lands.
1317
1542
def undef_combines : GICombineGroup<[undef_to_fp_zero, undef_to_int_zero,
1318
1543
undef_to_negative_one,
@@ -1368,8 +1593,9 @@ def fma_combines : GICombineGroup<[combine_fadd_fmul_to_fmad_or_fma,
1368
1593
def constant_fold_binops : GICombineGroup<[constant_fold_binop,
1369
1594
constant_fold_fp_binop]>;
1370
1595
1371
- def all_combines : GICombineGroup<[trivial_combines, insert_vec_elt_combines,
1372
- extract_vec_elt_combines, combines_for_extload, combine_extracted_vector_load,
1596
+ def all_combines : GICombineGroup<[trivial_combines, vector_ops_combines,
1597
+ insert_vec_elt_combines, extract_vec_elt_combines, combines_for_extload,
1598
+ combine_extracted_vector_load,
1373
1599
undef_combines, identity_combines, phi_combines,
1374
1600
simplify_add_to_sub, hoist_logic_op_with_same_opcode_hands, shifts_too_big,
1375
1601
reassocs, ptr_add_immed_chain,
0 commit comments