Default instruction output type to Any
If we're adding a bunch of instructions in the middle of an optimization pass, we don't want to use their (currently uninitialized) types because they start as Empty, and Empty is a subtype of everything. This breaks some optimizations. This Any will get refined the next time we call infer_types.
This commit is contained in:
parent
608fe6ee53
commit
b970ff1850
Notes:
git
2025-04-29 18:01:49 +00:00
@ -666,8 +666,12 @@ impl Function {
|
|||||||
// Add an instruction to the function without adding it to any block
|
// Add an instruction to the function without adding it to any block
|
||||||
fn new_insn(&mut self, insn: Insn) -> InsnId {
|
fn new_insn(&mut self, insn: Insn) -> InsnId {
|
||||||
let id = InsnId(self.insns.len());
|
let id = InsnId(self.insns.len());
|
||||||
|
if insn.has_output() {
|
||||||
|
self.insn_types.push(types::Any);
|
||||||
|
} else {
|
||||||
|
self.insn_types.push(types::Empty);
|
||||||
|
}
|
||||||
self.insns.push(insn);
|
self.insns.push(insn);
|
||||||
self.insn_types.push(types::Empty);
|
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2854,8 +2858,8 @@ mod opt_tests {
|
|||||||
bb0():
|
bb0():
|
||||||
PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
|
PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
|
||||||
PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
|
PatchPoint BOPRedefined(INTEGER_REDEFINED_OP_FLAG, BOP_PLUS)
|
||||||
v14:Fixnum[6] = Const Value(6)
|
v15:Fixnum[6] = Const Value(6)
|
||||||
Return v14
|
Return v15
|
||||||
"#]]);
|
"#]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user