@@ -1020,25 +1020,30 @@ static inline void minCut(const DataLayout &DL, LoopInfo &OrigLI,
1020
1020
for (auto U : V->users ()) {
1021
1021
if (auto I = dyn_cast<Instruction>(U)) {
1022
1022
for (auto pair : rematerializableAllocations) {
1023
- if (Intermediates.count (pair.first ) && pair.second .stores .count (I))
1024
- G[Node (V, true )].insert (Node (pair.first , false ));
1023
+ if (Intermediates.count (pair.first ) && pair.second .stores .count (I)) {
1024
+ if (V != pair.first )
1025
+ G[Node (V, true )].insert (Node (pair.first , false ));
1026
+ }
1025
1027
}
1026
1028
}
1027
1029
if (Intermediates.count (U)) {
1028
- G[Node (V, true )].insert (Node (U, false ));
1030
+ if (V != U)
1031
+ G[Node (V, true )].insert (Node (U, false ));
1029
1032
}
1030
1033
}
1031
1034
}
1032
1035
for (auto pair : rematerializableAllocations) {
1033
1036
if (Intermediates.count (pair.first )) {
1034
1037
for (LoadInst *L : pair.second .loads ) {
1035
1038
if (Intermediates.count (L)) {
1036
- G[Node (pair.first , true )].insert (Node (L, false ));
1039
+ if (L != pair.first )
1040
+ G[Node (pair.first , true )].insert (Node (L, false ));
1037
1041
}
1038
1042
}
1039
1043
for (auto L : pair.second .loadLikeCalls ) {
1040
1044
if (Intermediates.count (L.loadCall )) {
1041
- G[Node (pair.first , true )].insert (Node (L.loadCall , false ));
1045
+ if (L.loadCall != pair.first )
1046
+ G[Node (pair.first , true )].insert (Node (L.loadCall , false ));
1042
1047
}
1043
1048
}
1044
1049
}
0 commit comments