Skip to content

Commit 639b47c

Browse files
committed
reduce prevalence of push/pop sig instructions
1 parent 1bd403d commit 639b47c

File tree

4 files changed

+4
-41
lines changed

4 files changed

+4
-41
lines changed

src/compile/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,10 +1619,7 @@ code:
16191619
BindingKind::Func(f) if self.inlinable(f.instrs(&self.asm)) => {
16201620
if call {
16211621
// Inline instructions
1622-
self.push_instr(Instr::PushSig(f.signature()));
1623-
let instrs = EcoVec::from(f.instrs(&self.asm));
1624-
self.push_all_instrs(instrs);
1625-
self.push_instr(Instr::PopSig);
1622+
self.push_all_instrs(EcoVec::from(f.instrs(&self.asm)));
16261623
} else {
16271624
self.push_instr(Instr::PushFunc(f));
16281625
}

src/compile/modifier.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,7 @@ impl Compiler {
599599
instrs.extend(a_instrs);
600600
let sig = Signature::new(a_sig.args.max(b_sig.args), a_sig.outputs + b_sig.outputs);
601601
if call {
602-
self.push_instr(Instr::PushSig(sig));
603602
self.push_all_instrs(instrs);
604-
self.push_instr(Instr::PopSig);
605603
} else {
606604
let func =
607605
self.make_function(modified.modifier.span.clone().into(), sig, instrs);
@@ -627,9 +625,7 @@ impl Compiler {
627625
instrs.extend(a_instrs);
628626
let sig = Signature::new(a_sig.args + b_sig.args, a_sig.outputs + b_sig.outputs);
629627
if call {
630-
self.push_instr(Instr::PushSig(sig));
631628
self.push_all_instrs(instrs);
632-
self.push_instr(Instr::PopSig);
633629
} else {
634630
let func = self.make_function(
635631
FunctionId::Anonymous(modified.modifier.span.clone()),
@@ -682,25 +678,9 @@ impl Compiler {
682678
}
683679

684680
if let Some((f_before, f_after)) = under_instrs(&f_instrs, g_sig, self) {
685-
let before_sig = self.sig_of(&f_before, &f_span)?;
686-
let after_sig = self.sig_of(&f_after, &f_span)?;
687-
let mut instrs = if call {
688-
eco_vec![Instr::PushSig(before_sig)]
689-
} else {
690-
EcoVec::new()
691-
};
692-
instrs.extend(f_before);
693-
if call {
694-
instrs.push(Instr::PopSig);
695-
}
681+
let mut instrs = f_before;
696682
instrs.extend(g_instrs);
697-
if call {
698-
instrs.push(Instr::PushSig(after_sig));
699-
}
700683
instrs.extend(f_after);
701-
if call {
702-
instrs.push(Instr::PopSig);
703-
}
704684
if call {
705685
self.push_all_instrs(instrs);
706686
} else {
@@ -837,9 +817,7 @@ impl Compiler {
837817
}
838818
let sig = Signature::new(sig.args * 2, sig.outputs * 2);
839819
if call {
840-
self.push_instr(Instr::PushSig(sig));
841820
self.push_all_instrs(instrs);
842-
self.push_instr(Instr::PopSig);
843821
} else {
844822
let func =
845823
self.make_function(modified.modifier.span.clone().into(), sig, instrs);

src/optimize.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt;
22

33
use ecow::EcoVec;
44

5-
use crate::{check::instrs_all_signatures, Assembly, ImplPrimitive, Instr, Primitive};
5+
use crate::{Assembly, ImplPrimitive, Instr, Primitive};
66

77
pub(crate) fn optimize_instrs_mut(
88
instrs: &mut EcoVec<Instr>,
@@ -276,19 +276,6 @@ pub(crate) fn optimize_instrs_mut(
276276
instrs.pop();
277277
}
278278
}
279-
// Redundant identity
280-
(ins, Instr::Prim(Identity, span)) if !ins.is_empty() => {
281-
for i in (0..ins.len()).rev() {
282-
let Ok((sig, temp_sigs)) = instrs_all_signatures(&ins[i..]) else {
283-
continue;
284-
};
285-
if temp_sigs.iter().all(|&sig| sig == (0, 0)) && sig.outputs >= 1 {
286-
println!("{:?}", &ins[i..]);
287-
return;
288-
}
289-
}
290-
instrs.push(Instr::Prim(Identity, span));
291-
}
292279
(_, instr) => instrs.push(instr),
293280
}
294281
}

src/value.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ impl Value {
274274
Self::Box(_) => env.box_scalar_fill().map(Into::into),
275275
}
276276
}
277+
#[allow(dead_code)]
277278
pub(crate) fn fill_row(&self, env: &Uiua) -> Result<Self, &'static str> {
278279
if self.rank() == 0 {
279280
return self.fill_scalar(env);

0 commit comments

Comments
 (0)