@@ -730,7 +730,7 @@ namespace IGC {
730730 }
731731
732732 // /////////////////////////////////////////////////////////////////////////
733- bool CodeSinking::checkCongruent (const InstPair& values, InstVec& leaves, unsigned depth)
733+ bool CodeSinking::checkCongruent (std::vector<InstPair> &instMap, const InstPair& values, InstVec& leaves, unsigned depth)
734734 {
735735 Instruction* src0 = values.first ;
736736 Instruction* src1 = values.second ;
@@ -829,7 +829,7 @@ namespace IGC {
829829 if (iv0 && iv0->getParent () == src0->getParent () &&
830830 iv1 && iv1->getParent () == src1->getParent ())
831831 {
832- if (!checkCongruent (std::make_pair (iv0, iv1), tmpVec, depth + 1 ))
832+ if (!checkCongruent (instMap, std::make_pair (iv0, iv1), tmpVec, depth + 1 ))
833833 {
834834 equals = false ;
835835 break ;
@@ -843,7 +843,7 @@ namespace IGC {
843843 }
844844 if (equals)
845845 {
846- appendIfNotExist (std::make_pair (src0, src1));
846+ appendIfNotExist (std::make_pair (src0, src1), instMap );
847847 appendIfNotExist (leaves, tmpVec);
848848 return equals;
849849 }
@@ -889,7 +889,7 @@ namespace IGC {
889889 if (iv0 && iv0->getParent () == src0->getParent () &&
890890 iv1 && iv1->getParent () == src1->getParent ())
891891 {
892- if (!checkCongruent (std::make_pair (iv0, iv1), leaves, depth + 1 ))
892+ if (!checkCongruent (instMap, std::make_pair (iv0, iv1), leaves, depth + 1 ))
893893 {
894894 equals = false ;
895895 break ;
@@ -903,7 +903,7 @@ namespace IGC {
903903 }
904904 if (equals)
905905 {
906- appendIfNotExist (std::make_pair (src0, src1));
906+ appendIfNotExist (std::make_pair (src0, src1), instMap );
907907 appendIfNotExist (leaves, tmpVec);
908908 }
909909 return equals;
@@ -922,7 +922,11 @@ namespace IGC {
922922 src1 = dyn_cast<Instruction>(phi->getIncomingValue (1 ));
923923 if (src0 && src1 && src0 != src1)
924924 {
925- if (checkCongruent (std::make_pair (src0, src1), leaves, 0 ))
925+ // this vector maps all instructions leading to source0 of phi instruction to
926+ // the corresponding instructions of source1
927+ std::vector<InstPair> instMap;
928+
929+ if (checkCongruent (instMap, std::make_pair (src0, src1), leaves, 0 ))
926930 {
927931 BasicBlock* predBB = nullptr ;
928932 Instruction* insertPos = nullptr ;
@@ -1008,7 +1012,6 @@ namespace IGC {
10081012 }
10091013 }
10101014 }
1011- instMap.clear ();
10121015 return changed;
10131016 }
10141017
0 commit comments