ADLC generats incorrect operands when the same instruct expanded several times.
Operands from the last expanded instruct are used for all cases.
instruct divI_reg_reg(iRegI dst, iRegI src1, iRegI src2) %{
match(Set dst (DivI src1 src2));
ins_cost((2+71)*DEFAULT_COST);
expand %{
iRegIsafe tmp1;
iRegIsafe tmp2;
convI2L_helper(tmp1, src1);
convI2L_helper(tmp2, src2);
divI_reg_reg_helper(dst, tmp1, tmp2);
%}
%}
convI2L_helperNode *n0 = new convI2L_helperNode();
n0->add_req(_in[0]);
n0->set_opnd_array(0, state->MachOperGenerator( IREGISAFE, n0, C ));
tmp4 = n0;
n0->set_opnd_array(1, opnd_array(2)->clone()); // src2
if(tmp2 == this) {
for(unsigned i = 0; i < num2; i++) {
n0->add_req(_in[i + idx2]);
}
}
else n0->add_req(tmp2);
result = n0->Expand( state, proj_list );
convI2L_helperNode *n1 = new convI2L_helperNode();
n1->add_req(_in[0]);
n1->set_opnd_array(0, state->MachOperGenerator( IREGISAFE, n1, C ));
tmp4 = n1;
n1->set_opnd_array(1, opnd_array(2)->clone()); // src2
if(tmp2 == this) {
for(unsigned i = 0; i < num2; i++) {
n1->add_req(_in[i + idx2]);
}
}
else n1->add_req(tmp2);
Operands from the last expanded instruct are used for all cases.
instruct divI_reg_reg(iRegI dst, iRegI src1, iRegI src2) %{
match(Set dst (DivI src1 src2));
ins_cost((2+71)*DEFAULT_COST);
expand %{
iRegIsafe tmp1;
iRegIsafe tmp2;
convI2L_helper(tmp1, src1);
convI2L_helper(tmp2, src2);
divI_reg_reg_helper(dst, tmp1, tmp2);
%}
%}
convI2L_helperNode *n0 = new convI2L_helperNode();
n0->add_req(_in[0]);
n0->set_opnd_array(0, state->MachOperGenerator( IREGISAFE, n0, C ));
tmp4 = n0;
n0->set_opnd_array(1, opnd_array(2)->clone()); // src2
if(tmp2 == this) {
for(unsigned i = 0; i < num2; i++) {
n0->add_req(_in[i + idx2]);
}
}
else n0->add_req(tmp2);
result = n0->Expand( state, proj_list );
convI2L_helperNode *n1 = new convI2L_helperNode();
n1->add_req(_in[0]);
n1->set_opnd_array(0, state->MachOperGenerator( IREGISAFE, n1, C ));
tmp4 = n1;
n1->set_opnd_array(1, opnd_array(2)->clone()); // src2
if(tmp2 == this) {
for(unsigned i = 0; i < num2; i++) {
n1->add_req(_in[i + idx2]);
}
}
else n1->add_req(tmp2);