@@ -441,20 +441,26 @@ impl<'f> Context<'f> {
441
441
new_condition : ValueId ,
442
442
condition_value : FieldElement ,
443
443
) -> Branch {
444
- self . push_condition ( jmpif_block, new_condition) ;
445
- self . insert_current_side_effects_enabled ( ) ;
446
- let old_stores = std:: mem:: take ( & mut self . store_values ) ;
444
+ if destination == self . branch_ends [ & jmpif_block] {
445
+ // If the branch destination is the same as the end of the branch, this must be the
446
+ // 'else' case of an if with no else - so there is no else branch.
447
+ Branch { condition : new_condition, last_block : jmpif_block, store_values : HashMap :: new ( ) }
448
+ } else {
449
+ self . push_condition ( jmpif_block, new_condition) ;
450
+ self . insert_current_side_effects_enabled ( ) ;
451
+ let old_stores = std:: mem:: take ( & mut self . store_values ) ;
447
452
448
- // Remember the old condition value is now known to be true/false within this branch
449
- let known_value = self . function . dfg . make_constant ( condition_value, Type :: bool ( ) ) ;
450
- self . values . insert ( old_condition, known_value) ;
453
+ // Remember the old condition value is now known to be true/false within this branch
454
+ let known_value = self . function . dfg . make_constant ( condition_value, Type :: bool ( ) ) ;
455
+ self . values . insert ( old_condition, known_value) ;
451
456
452
- let final_block = self . inline_block ( destination, & [ ] ) ;
457
+ let final_block = self . inline_block ( destination, & [ ] ) ;
453
458
454
- self . conditions . pop ( ) ;
455
- let stores_in_branch = std:: mem:: replace ( & mut self . store_values , old_stores) ;
459
+ self . conditions . pop ( ) ;
460
+ let stores_in_branch = std:: mem:: replace ( & mut self . store_values , old_stores) ;
456
461
457
- Branch { condition : new_condition, last_block : final_block, store_values : stores_in_branch }
462
+ Branch { condition : new_condition, last_block : final_block, store_values : stores_in_branch }
463
+ }
458
464
}
459
465
460
466
/// Inline the ending block of a branch, the point where all blocks from a jmpif instruction
0 commit comments