loops: dont do an extra header duplication for self-loops
MODIFY
ir/function.cpp
ir/function.cpp
@@ -486,7 +486,7 @@ void Function::unroll(unsigned k) {
// exit. Otherwise the last iteration would be wasted.
// Here we assume the header is an exit, as that's the common case.
// If not, this extra duplication is wasteful.
- {
+ if (bbmap.size() > 1) {
auto &copies = bbmap.at(header);
copies.emplace_back(&cloneBB(*header, "#exit", bbmap, vmap));
unrolled_bbs.emplace_back(copies.back());

RENAME
tests/alive-tv/loops/fp_fraction.srctgt.ll
tests/alive-tv/loops/ctlz.srctgt.ll
MODIFY
tests/alive-tv/loops/phi2-fail.srctgt.ll
tests/alive-tv/loops/phi2-fail.srctgt.ll
-; TEST-ARGS: -src-unroll=2 -tgt-unroll=2
+; TEST-ARGS: -src-unroll=3 -tgt-unroll=3
; ERROR: Value mismatch
define i32 @src() {

MODIFY
tests/alive-tv/loops/phi2.srctgt.ll
tests/alive-tv/loops/phi2.srctgt.ll
-; TEST-ARGS: -src-unroll=2 -tgt-unroll=2
+; TEST-ARGS: -src-unroll=3 -tgt-unroll=3
define i32 @src() {
entry:

MODIFY
tests/alive-tv/loops/phi4-fail.srctgt.ll
tests/alive-tv/loops/phi4-fail.srctgt.ll
-; TEST-ARGS: -src-unroll=2 -tgt-unroll=2
+; TEST-ARGS: -src-unroll=3 -tgt-unroll=3
; ERROR: Value mismatch
define i32 @src(i1 %bool) {

MODIFY
tests/alive-tv/loops/phi4.srctgt.ll
tests/alive-tv/loops/phi4.srctgt.ll
-; TEST-ARGS: -src-unroll=2 -tgt-unroll=2
+; TEST-ARGS: -src-unroll=3 -tgt-unroll=3
define i32 @src(i1 %bool) {
entry:

loops: dont do an extra header duplication for self-loops