A DESCRIPTION OF THE PROBLEM :
LIRAssembler::comve(cond, opr1, opr2, result) allows that opr1 and result are the same register, so there are two places where we could replace the redundant tmp register with the result register.
For example, the tmp register in LIRGenerator::do_TableSwitch is allocated to receive the result register value, and then it's used by cmove as a compare opr. It could be simplified as __ cmove(lir_cond_equal, data_offset_reg, LIR_OprFact::intptrConst(count_offset), data_offset_reg, T_INT), therefore the tmp register is reduced.
void LIRGenerator::do_TableSwitch(TableSwitch* x) {
// ...
__ move(LIR_OprFact::intptrConst(default_count_offset), data_offset_reg);
for (int i = 0; i < len; i++) {
int count_offset = md->byte_offset_of_slot(data, MultiBranchData::case_count_offset(i));
__ cmp(lir_cond_equal, value, i + lo_key);
__ move(data_offset_reg, tmp_reg);
__ cmove(lir_cond_equal,
LIR_OprFact::intptrConst(count_offset),
tmp_reg,
data_offset_reg, T_INT);
}
The same problem happens in LIRGenerator::do_LookupSwitch on idk master.
LIRAssembler::comve(cond, opr1, opr2, result) allows that opr1 and result are the same register, so there are two places where we could replace the redundant tmp register with the result register.
For example, the tmp register in LIRGenerator::do_TableSwitch is allocated to receive the result register value, and then it's used by cmove as a compare opr. It could be simplified as __ cmove(lir_cond_equal, data_offset_reg, LIR_OprFact::intptrConst(count_offset), data_offset_reg, T_INT), therefore the tmp register is reduced.
void LIRGenerator::do_TableSwitch(TableSwitch* x) {
// ...
__ move(LIR_OprFact::intptrConst(default_count_offset), data_offset_reg);
for (int i = 0; i < len; i++) {
int count_offset = md->byte_offset_of_slot(data, MultiBranchData::case_count_offset(i));
__ cmp(lir_cond_equal, value, i + lo_key);
__ move(data_offset_reg, tmp_reg);
__ cmove(lir_cond_equal,
LIR_OprFact::intptrConst(count_offset),
tmp_reg,
data_offset_reg, T_INT);
}
The same problem happens in LIRGenerator::do_LookupSwitch on idk master.
- links to
-
Review(master) openjdk/jdk/27307