@@ -1495,6 +1495,25 @@ OptoReg::Name PhaseChaitin::bias_color( LRG &lrg, int chunk ) {
1495
1495
}
1496
1496
}
1497
1497
1498
+ copy_lrg = _lrg_map.find (lrg._copy_bias2 );
1499
+ if (copy_lrg != 0 ) {
1500
+ // If he has a color,
1501
+ if (!_ifg->_yanked ->test (copy_lrg)) {
1502
+ OptoReg::Name reg = lrgs (copy_lrg).reg ();
1503
+ // And it is legal for you,
1504
+ if (is_legal_reg (lrg, reg, chunk))
1505
+ return reg;
1506
+ } else if ( chunk == 0 ) {
1507
+ // Choose a color which is legal for him
1508
+ RegMask tempmask = lrg.mask ();
1509
+ tempmask.AND (lrgs (copy_lrg).mask ());
1510
+ tempmask.clear_to_sets (lrg.num_regs ());
1511
+ OptoReg::Name reg = find_first_set (lrg, tempmask, chunk);
1512
+ if (OptoReg::is_valid (reg))
1513
+ return reg;
1514
+ }
1515
+ }
1516
+
1498
1517
// If no bias info exists, just go with the register selection ordering
1499
1518
if (lrg._is_vector || lrg.num_regs () == 2 || lrg.is_scalable ()) {
1500
1519
// Find an aligned set
@@ -1617,6 +1636,49 @@ uint PhaseChaitin::Select( ) {
1617
1636
}
1618
1637
}
1619
1638
}
1639
+
1640
+ auto is_commutative_oper = [](MachNode* def) {
1641
+ if (def) {
1642
+ switch (def->ideal_Opcode ()) {
1643
+ case Op_AddI: case Op_AddL:
1644
+ case Op_MulI: case Op_MulL:
1645
+ case Op_XorI: case Op_XorL:
1646
+ case Op_OrI: case Op_OrL:
1647
+ case Op_AndI: case Op_AndL:
1648
+ return true ;
1649
+ default :
1650
+ return false ;
1651
+ }
1652
+ }
1653
+ return false ;
1654
+ };
1655
+
1656
+ if (X86_ONLY (UseAPX) NOT_X86 (false )) {
1657
+ Node* def = lrg->_def ;
1658
+ MachNode* mdef = def->is_Mach () ? def->as_Mach () : nullptr ;
1659
+ uint16_t num_oprds = mdef != nullptr ? mdef->num_opnds () : 0 ;
1660
+ if (num_oprds >= 2 ) {
1661
+ Node* in1 = mdef->in (mdef->operand_index (1 ));
1662
+ uint lrin1 = _lrg_map.find (in1);
1663
+ // If a def does not interfere with first input's def,
1664
+ // then bias its color towards its input's def.
1665
+ if (lrin1 != 0 && lrg->_copy_bias == 0 && _ifg->test_edge_sq (lidx, lrin1) == 0 ) {
1666
+ lrg->_copy_bias = lrin1;
1667
+ }
1668
+ }
1669
+
1670
+ if (is_commutative_oper (mdef)) {
1671
+ assert (num_oprds >= 3 , " " );
1672
+ Node* in2 = mdef->in (mdef->operand_index (2 ));
1673
+ uint lrin2 = _lrg_map.find (in2);
1674
+ // If a def does not interfere with second input's def,
1675
+ // then bias its color towards its input's def.
1676
+ if (lrin2 != 0 && lrg->_copy_bias2 == 0 && _ifg->test_edge_sq (lidx, lrin2) == 0 ) {
1677
+ lrg->_copy_bias2 = lrin2;
1678
+ }
1679
+ }
1680
+ }
1681
+
1620
1682
// assert(is_allstack == lrg->mask().is_AllStack(), "nbrs must not change AllStackedness");
1621
1683
// Aligned pairs need aligned masks
1622
1684
assert (!lrg->_is_vector || !lrg->_fat_proj , " sanity" );
0 commit comments