@@ -44,10 +44,10 @@ struct ExceptionOrPassPatternElimination {
44
44
bool arm1_starts_with_exception = (*arm1_start)->kind () == prim::RaiseException;
45
45
bool arm2_starts_with_exception = (*arm2_start)->kind () == prim::RaiseException;
46
46
47
- if (!arm1_starts_with_exception && !arm2_starts_with_exception) {
47
+ // if (!arm1_starts_with_exception && !arm2_starts_with_exception) {
48
48
// Neither arm matches the pattern
49
- return false ;
50
- }
49
+ // return false;
50
+ // }
51
51
52
52
// / Check if this Node hosts a pattern like so:
53
53
// / = prim::If(%5958)
@@ -57,14 +57,12 @@ struct ExceptionOrPassPatternElimination {
57
57
// / block1():
58
58
// / -> ()
59
59
if (arm1_starts_with_exception) {
60
- if ((*(++arm1_start))->kind () ! = prim::Return) {
60
+ if ((*(++arm1_start))->kind () = = prim::Return) {
61
61
// 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
+ }
68
66
}
69
67
}
70
68
@@ -76,25 +74,23 @@ struct ExceptionOrPassPatternElimination {
76
74
// / = prim::RaiseException(%45)
77
75
// / -> ()
78
76
if (arm2_starts_with_exception) {
79
- if ((*(++arm2_start))->kind () ! = prim::Return) {
77
+ if ((*(++arm2_start))->kind () = = prim::Return) {
80
78
// 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
+ }
87
83
}
88
84
}
89
85
90
- return true ;
86
+ return false ;
91
87
}
92
88
93
89
void findExceptionOrPassNodes (Block* b) {
94
90
for (auto it = b->nodes ().begin (); it != b->nodes ().end (); it++) {
95
91
auto n = *it;
96
92
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);
98
94
it.destroyCurrent ();
99
95
}
100
96
}
@@ -107,6 +103,9 @@ struct ExceptionOrPassPatternElimination {
107
103
void EliminateExceptionOrPassPattern (std::shared_ptr<Graph> graph) {
108
104
ExceptionOrPassPatternElimination eppe (std::move (graph));
109
105
eppe.run ();
106
+ if (graph) {
107
+ LOG_ERROR (" Post Eliminate Exception or Pass Patterns: " << *graph);
108
+ }
110
109
}
111
110
112
111
} // namespace passes
0 commit comments