diff --git a/include/pass_mpi_collective.hpp b/include/pass_mpi_collective.hpp
index dd9b512dcc7b8cbd27c38fb9c8ef8eac10344fbc..dfad6a3785e817ccf4b6c4ea2d3208e058f87adf 100644
--- a/include/pass_mpi_collective.hpp
+++ b/include/pass_mpi_collective.hpp
@@ -2,8 +2,8 @@
 #include <gcc-plugin.h>
 // declare opt_pass
 #include <tree-pass.h>
-// vector
-#include <vector>
+// set
+#include <set>
 
 /* Enum to represent the collective operations */
 #define DEFMPICOLLECTIVES(CODE, NAME) CODE,
@@ -25,10 +25,10 @@ const char *const mpi_collective_name[] =
 struct bb_data
 {
 	mpi_collective_code mpi_code;
-	std::vector<basic_block> dom;
-	std::vector<basic_block> post_dom;
-	std::vector<basic_block> dom_front;
-	std::vector<basic_block> post_dom_front;
+	std::set<basic_block> dom;
+	std::set<basic_block> post_dom;
+	std::set<basic_block> dom_front;
+	std::set<basic_block> post_dom_front;
 };
 
 class pass_mpi_collective : public opt_pass
@@ -59,6 +59,8 @@ public:
 
 	// calculate dominances
 	void label_dom(function *fun);
+	void compute_dominance_frontiers(function *fun);
+	void compute_post_dominance_frontiers(function *fun);
 	void free_dom_data();
 
 private:
diff --git a/src/pass_mpi_collective.cpp b/src/pass_mpi_collective.cpp
index 8088361cc7946dde326089ffd8c7fee50d0ab455..d902530ce65a5925910fc2ad2052ebc13704b0bf 100644
--- a/src/pass_mpi_collective.cpp
+++ b/src/pass_mpi_collective.cpp
@@ -10,8 +10,8 @@
 #include <gimple-iterator.h>
 // basename
 #include <filesystem>
-// vector
-#include <vector>
+// set
+#include <set>
 
 // our pass
 #include "pass_mpi_collective.hpp"
@@ -59,6 +59,8 @@ unsigned int pass_mpi_collective::execute(function *fun)
 	alloc_bb_aux(fun);
 	label_collec(fun);
 	label_dom(fun);
+	compute_dominance_frontiers(fun);
+	compute_post_dominance_frontiers(fun);
 	cfgviz_dump(fun, "_split");
 
 	free_dom_data();
@@ -245,7 +247,7 @@ void pass_mpi_collective::label_dom(function *fun)
 		{
 			if (dom_gccvec[i]->index != bb->index)
 			{
-				data->dom.push_back(dom_gccvec[i]);
+				data->dom.insert(dom_gccvec[i]);
 			}
 		}
 
@@ -261,7 +263,7 @@ void pass_mpi_collective::label_dom(function *fun)
 		{
 			if (post_dom_gccvec[i]->index != bb->index)
 			{
-				data->post_dom.push_back(post_dom_gccvec[i]);
+				data->post_dom.insert(post_dom_gccvec[i]);
 			}
 		}
 		//for (basic_block bb2 : *post_dom)
@@ -272,13 +274,79 @@ void pass_mpi_collective::label_dom(function *fun)
 	}
 }
 
+void pass_mpi_collective::compute_dominance_frontiers(function *fun)
+{
+	edge p;
+	edge_iterator ei;
+	basic_block b;
+
+	FOR_EACH_BB_FN(b, fun)
+	{
+		if (EDGE_COUNT(b->preds) >= 2)
+		{
+			basic_block domsb = get_immediate_dominator(CDI_DOMINATORS, b);
+			FOR_EACH_EDGE(p, ei, b->preds)
+			{
+				basic_block runner = p->src;
+				if (runner == ENTRY_BLOCK_PTR_FOR_FN(fun))
+				{
+					continue;
+				}
+				while (runner != domsb)
+				{
+					bb_data *data = (bb_data *) runner->aux;
+					if (data->dom_front.count(b) > 0)
+					{
+						break;
+					}
+					data->dom_front.insert(b);
+					runner = get_immediate_dominator(CDI_DOMINATORS, runner);
+				}
+			}
+		}
+	}
+}
+
+void pass_mpi_collective::compute_post_dominance_frontiers(function *fun)
+{
+	edge p;
+	edge_iterator ei;
+	basic_block b;
+
+	FOR_EACH_BB_FN(b, fun)
+	{
+		if (EDGE_COUNT(b->succs) >= 2)
+		{
+			basic_block domsb = get_immediate_dominator(CDI_POST_DOMINATORS, b);
+			FOR_EACH_EDGE(p, ei, b->succs)
+			{
+				basic_block runner = p->dest;
+				if (runner == EXIT_BLOCK_PTR_FOR_FN(fun))
+				{
+					continue;
+				}
+				while (runner != domsb)
+				{
+					bb_data *data = (bb_data *) runner->aux;
+					if (data->post_dom_front.count(b) > 0)
+					{
+						break;
+					}
+					data->post_dom_front.insert(b);
+					runner = get_immediate_dominator(CDI_POST_DOMINATORS, runner);
+				}
+			}
+		}
+	}
+}
+
 void pass_mpi_collective::free_dom_data()
 {
 	free_dominance_info(CDI_DOMINATORS);
 	free_dominance_info(CDI_POST_DOMINATORS);
 }
 
-//============================  GRAPHVIZ  =====================================
+//============================	GRAPHVIZ  =====================================
 
 /* Build a filename (as a string) based on function name */
 char *pass_mpi_collective::cfgviz_generate_filename(function *fun,
@@ -342,6 +410,26 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out)
 			fprintf(out, ")");
 		}
 
+		if (! data->dom_front.empty())
+		{
+			fprintf(out, "|dom_front(");
+			for (basic_block bb2 : data->dom_front)
+			{
+				fprintf(out, "%d,", bb2->index);
+			}
+			fprintf(out, ")");
+		}
+
+		if (! data->post_dom_front.empty())
+		{
+			fprintf(out, "|post_dom_front(");
+			for (basic_block bb2 : data->post_dom_front)
+			{
+				fprintf(out, "%d,", bb2->index);
+			}
+			fprintf(out, ")");
+		}
+
 		fprintf(out, "\" shape=ellipse]\n");
 
 		FOR_EACH_EDGE(e, eit, bb->succs)