Skip to content

Commit 8508a1e

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

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/hotspot/share/opto/chaitin.cpp

Lines changed: 52 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,39 @@ uint PhaseChaitin::Select( ) {
16171636
}
16181637
}
16191638
}
1639+
1640+
auto is_commutative_oper = [](MachNode* def) {
1641+
switch(def->ideal_Opcode()) {
1642+
case Op_AddI: case Op_AddL:
1643+
case Op_MulI: case Op_MulL:
1644+
case Op_XorI: case Op_XorL:
1645+
case Op_OrI: case Op_OrL:
1646+
case Op_AndI: case Op_AndL:
1647+
return true;
1648+
default:
1649+
return false;
1650+
}
1651+
};
1652+
1653+
if (UseAPX) {
1654+
Node* def = lrg->_def;
1655+
if (def->is_Mach()) {
1656+
MachNode* mdef = def->as_Mach();
1657+
for (uint i = mdef->oper_input_base(); i < def->req(); i++) {
1658+
uint lruseidx = _lrg_map.find(def->in(i));
1659+
// If a def does not interfere with any of its use's def
1660+
// then bias def color towards its it.
1661+
if (lruseidx != 0 && _ifg->test_edge_sq(lidx, lruseidx) == 0) {
1662+
if (lrg->_copy_bias == 0) {
1663+
lrg->_copy_bias = lruseidx;
1664+
} else if (lrg->_copy_bias2 == 0 && is_commutative_oper(mdef)) {
1665+
lrg->_copy_bias2 = lruseidx;
1666+
}
1667+
}
1668+
}
1669+
}
1670+
}
1671+
16201672
//assert(is_allstack == lrg->mask().is_AllStack(), "nbrs must not change AllStackedness");
16211673
// Aligned pairs need aligned masks
16221674
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)