@@ -44,10 +44,10 @@ struct ExceptionOrPassPatternElimination {
4444 bool arm1_starts_with_exception = (*arm1_start)->kind () == prim::RaiseException;
4545 bool arm2_starts_with_exception = (*arm2_start)->kind () == prim::RaiseException;
4646
47- if (!arm1_starts_with_exception && !arm2_starts_with_exception) {
47+ // if (!arm1_starts_with_exception && !arm2_starts_with_exception) {
4848 // Neither arm matches the pattern
49- return false ;
50- }
49+ // return false;
50+ // }
5151
5252 // / Check if this Node hosts a pattern like so:
5353 // / = prim::If(%5958)
@@ -57,14 +57,12 @@ struct ExceptionOrPassPatternElimination {
5757 // / block1():
5858 // / -> ()
5959 if (arm1_starts_with_exception) {
60- if ((*(++arm1_start))->kind () ! = prim::Return) {
60+ if ((*(++arm1_start))->kind () = = prim::Return) {
6161 // Make sure that block0 is solely just the exception and the return
62- return false ;
63- }
64-
65- if ((*(arm2_start))->kind () != prim::Return) {
66- // Make sure that block1 is solely the return
67- return false ;
62+ if ((*(arm2_start))->kind () == prim::Return) {
63+ // Make sure that block1 is solely the return
64+ return true ;
65+ }
6866 }
6967 }
7068
@@ -76,25 +74,23 @@ struct ExceptionOrPassPatternElimination {
7674 // / = prim::RaiseException(%45)
7775 // / -> ()
7876 if (arm2_starts_with_exception) {
79- if ((*(++arm2_start))->kind () ! = prim::Return) {
77+ if ((*(++arm2_start))->kind () = = prim::Return) {
8078 // Make sure that block1 is solely just the exception and the return
81- return false ;
82- }
83-
84- if ((*(arm1_start))->kind () != prim::Return) {
85- // Make sure that block0 is solely the return
86- return false ;
79+ if ((*(arm1_start))->kind () == prim::Return) {
80+ // Make sure that block0 is solely the return
81+ return true ;
82+ }
8783 }
8884 }
8985
90- return true ;
86+ return false ;
9187 }
9288
9389 void findExceptionOrPassNodes (Block* b) {
9490 for (auto it = b->nodes ().begin (); it != b->nodes ().end (); it++) {
9591 auto n = *it;
9692 if (n->kind () == prim::If && isExceptionOrPassNode (n)) {
97- LOG_GRAPH (" Found that node " << *n << " is an exception or pass node (EliminateChecks)" << std::endl);
93+ LOG_ERROR (" Found that node " << *n << " is an exception or pass node (EliminateChecks)" << std::endl);
9894 it.destroyCurrent ();
9995 }
10096 }
@@ -107,6 +103,9 @@ struct ExceptionOrPassPatternElimination {
107103void EliminateExceptionOrPassPattern (std::shared_ptr<Graph> graph) {
108104 ExceptionOrPassPatternElimination eppe (std::move (graph));
109105 eppe.run ();
106+ if (graph) {
107+ LOG_ERROR (" Post Eliminate Exception or Pass Patterns: " << *graph);
108+ }
110109}
111110
112111} // namespace passes
0 commit comments