Skip to content

Commit

Permalink
Teach genLoadIf that a () else branch is the same as no else branch.
Browse files Browse the repository at this point in the history
This avoids generating dead code gotos.
  • Loading branch information
sjrd committed Aug 28, 2018
1 parent 011d5c3 commit 239bd89
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
val success = new asm.Label
val failure = new asm.Label

val hasElse = !elsep.isEmpty
val hasElse = !elsep.isEmpty && (elsep match {
case Literal(value) if value.tag == UnitTag => false
case _ => true
})
val postIf = if (hasElse) new asm.Label else failure

genCond(condp, success, failure, targetIfNoJump = success)
Expand Down

0 comments on commit 239bd89

Please sign in to comment.