Skip to content
Permalink
Browse files

Emit simpler code for lowered while loop

Don't emit a subtraction instruction sequence when we can just do it in
the optimizer.
  • Loading branch information...
jnthn committed Apr 8, 2019
1 parent 17643d4 commit 29ce2ce3867709eca47bdfb99ddc73323635c8b3
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/Perl6/Optimizer.nqp
@@ -2485,7 +2485,9 @@ class Perl6::Optimizer {
QAST::Var.new(
:name($it_var), :scope<local>, :decl<var>, :returns(int)
),
QAST::Op.new( :op<sub_i>, $start, QAST::IVal.new( :value($step)))
nqp::istype($start, QAST::IVal)
?? QAST::IVal.new( :value($start.value - $step) )
!! QAST::Op.new( :op<sub_i>, $start, QAST::IVal.new( :value($step)))
),

# my int $last := $end

0 comments on commit 29ce2ce

Please sign in to comment.
You can’t perform that action at this time.