@@ -592,25 +592,6 @@ interchangeable_atoms(bool global, block b) const {
592592 class_atoms.insert (set<register_atom>(input->calleesaved .begin (),
593593 input->calleesaved .end ()));
594594
595- // add individual atoms in pack register classes
596- set<pair<register_class, int > > rcws;
597- for (block b : B) {
598- for (unsigned int pi = 0 ; pi < input->bpacked [b].size (); pi++) {
599- operand p = input->bpacked [b][pi][0 ];
600- register_class rc = input->bpclass [b][pi];
601- rcws.insert (make_pair (rc, input->operand_width [p]));
602- }
603- }
604- for (pair<register_class, int > rcw : rcws) {
605- for (register_atom ra : input->atoms [rcw.first ]) {
606- set<register_atom> rc_atoms;
607- for (int w = 0 ; w < rcw.second ; w++) {
608- rc_atoms.insert (ra + w);
609- }
610- class_atoms.insert (rc_atoms);
611- }
612- }
613-
614595 set<register_atom> finite;
615596 for (auto ra : interchangeable) finite.insert (ra.first );
616597
@@ -1032,32 +1013,47 @@ void Model::post_alignment_constraints(block b) {
10321013
10331014void Model::post_packing_constraints (block b) {
10341015
1035- // Bound operands are packed together with free operands assigned to
1036- // pack register classes :
1016+ // Bound operands are packed together with free operands if the definer
1017+ // operation is implemented by a pack instruction :
10371018
10381019 for (unsigned int pi = 0 ; pi < input->bpacked [b].size (); pi++) {
10391020 operand p = input->bpacked [b][pi][0 ], q = input->bpacked [b][pi][1 ];
1040- register_class rc = input->bpclass [b][pi];
10411021 int w = input->operand_width [p];
1022+ vector<instruction> pis = input->bpinstrs [b][pi];
1023+
1024+ // instruction that defines the temporary connected to p
1025+ IntVar di (*this , 0 , input->I .size () - 1 );
1026+ IntVarArgs is;
1027+ for (temporary t : input->temps [p]) {
1028+ if (t == NULL_TEMPORARY ) {
1029+ is << var (NULL_INSTRUCTION );
1030+ } else {
1031+ operation d = input->def_opr [t];
1032+ IntVar instr (*this , 0 , input->I .size () - 1 );
1033+ element (*this , IntArgs (input->instructions [d]), i (d), instr);
1034+ is << instr;
1035+ }
1036+ }
1037+ element (*this , is, y (p), di);
1038+ BoolVar pack_definer (*this , 0 , 1 );
1039+ IntArgs pack_is (pis);
1040+ dom (*this , di, IntSet (pack_is), pack_definer, ipl);
10421041
10431042 BoolVarArgs cases;
10441043 IntVarArgs ryps;
1045- BoolVar ryp_in_rc (*this , 0 , 1 );
1046- IntArgs rc_atoms (input->atoms [rc]);
1047- dom (*this , ry (p), IntSet (rc_atoms), ryp_in_rc, ipl);
10481044
10491045 // first case: bound operand packed in high component
1050- cases << var (x (p) && ryp_in_rc && ((ry (p) % (w*2 )) == 0 ));
1046+ cases << var (x (p) && pack_definer && ((ry (p) % (w*2 )) == 0 ));
10511047 ryps << var (ry (p) + w);
10521048
10531049 // second case: bound operand packed in low component
1054- cases << var (x (p) && ryp_in_rc && ((ry (p) % (w*2 )) != 0 ));
1050+ cases << var (x (p) && pack_definer && ((ry (p) % (w*2 )) != 0 ));
10551051 ryps << var (ry (p) - w);
10561052
10571053 // third case: bound operand not packed
10581054 BoolVarArgs conds;
10591055 conds << x (p);
1060- conds << ryp_in_rc ;
1056+ conds << pack_definer ;
10611057 cases << var (sum (conds) < 2 );
10621058 IntVar any (*this , Gecode::Int::Limits::min, Gecode::Int::Limits::max);
10631059 ryps << any;
0 commit comments