|
4 | 4 |
|
5 | 5 | #include <set> |
6 | 6 |
|
7 | | -#include "IR/opcode_gen.h" |
8 | 7 | #include "BE/Base/sanity.h" |
9 | 8 | #include "BE/Base/serialize.h" |
| 9 | +#include "IR/opcode_gen.h" |
10 | 10 | #include "Util/parse.h" |
11 | 11 |
|
12 | 12 | namespace cwerg::base { |
@@ -302,7 +302,8 @@ void FunRemoveEmptyBbls(Fun fun) { |
302 | 302 | bbls_keep.push_back(bbl); |
303 | 303 | continue; |
304 | 304 | } |
305 | | - // ASSERT(FunBblList::Head(fun) != bbl, "cannot remove entry bbl in fun " << Name(fun)); |
| 305 | + // ASSERT(FunBblList::Head(fun) != bbl, "cannot remove entry bbl in fun " << |
| 306 | + // Name(fun)); |
306 | 307 | ASSERT(out_edg == BblSuccEdgList::Tail(bbl) && |
307 | 308 | !BblSuccEdgList::IsSentinel(out_edg), |
308 | 309 | "must have one out edge:\n" |
@@ -382,14 +383,15 @@ void FunAddUnconditionalBranches(Fun fun) { |
382 | 383 | // If it has a fall-through there is at least one succ edge |
383 | 384 | ASSERT(!BblSuccEdgList::IsSentinel(edg1), ""); |
384 | 385 | ASSERT(!BblSuccEdgList::IsSentinel(edg2), ""); |
| 386 | + // Note, next might be a sentinel |
385 | 387 | const Bbl next = FunBblList::Next(bbl); |
386 | | - ASSERT(!FunBblList::IsSentinel(next), ""); |
387 | | - // Single Edge case: |
388 | 388 | if (edg1 == edg2) { |
| 389 | + // Single Edge case: |
389 | 390 | if (next != EdgSuccBbl(edg1)) { |
390 | 391 | BblInsAdd(bbl, InsNewBra(EdgSuccBbl(edg1))); |
391 | 392 | } |
392 | 393 | } else { |
| 394 | + // Two Edges case: if one edge goes to next, we can just flip the condition and target of the cond bra |
393 | 395 | ASSERT(InsOpcode(last).kind == OPC_KIND::COND_BRA, ""); |
394 | 396 | ASSERT(BblSuccEdgList::Next(edg1) == edg2, ""); |
395 | 397 | const Bbl target = Bbl(InsOperand(last, 2)); |
|
0 commit comments