Skip to content

Commit d0f91df

Browse files
author
Jatin Bhateja
committed
8351016: RA support for EVEX to REX/REX2 demotion to optimize NDD instructions
1 parent e024568 commit d0f91df

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/hotspot/share/opto/chaitin.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,25 @@ OptoReg::Name PhaseChaitin::bias_color( LRG &lrg, int chunk ) {
14951495
}
14961496
}
14971497

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+
14981517
// If no bias info exists, just go with the register selection ordering
14991518
if (lrg._is_vector || lrg.num_regs() == 2 || lrg.is_scalable()) {
15001519
// Find an aligned set
@@ -1617,6 +1636,49 @@ uint PhaseChaitin::Select( ) {
16171636
}
16181637
}
16191638
}
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+
16201682
//assert(is_allstack == lrg->mask().is_AllStack(), "nbrs must not change AllStackedness");
16211683
// Aligned pairs need aligned masks
16221684
assert(!lrg->_is_vector || !lrg->_fat_proj, "sanity");

src/hotspot/share/opto/chaitin.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class LRG : public ResourceObj {
6363

6464
uint _risk_bias; // Index of LRG which we want to avoid color
6565
uint _copy_bias; // Index of LRG which we want to share color
66+
uint _copy_bias2; // Index of second LRG which we want to share color
6667

6768
uint _next; // Index of next LRG in linked list
6869
uint _prev; // Index of prev LRG in linked list

0 commit comments

Comments
 (0)