Mark the jump_table_entry Instruction as loading;

This commit is contained in:
Benjamin Bouvier
2019-06-26 17:10:20 +02:00
parent 079ccf1f6e
commit 83336290c2
3 changed files with 32 additions and 2 deletions

View File

@@ -164,7 +164,7 @@ jump_table_entry = Instruction(
Currently, the only type supported is entries which are relative to the Currently, the only type supported is entries which are relative to the
base of the jump table. base of the jump table.
""", """,
ins=(x, addr, Size, JT), outs=entry) ins=(x, addr, Size, JT), outs=entry, can_load=True)
jump_table_base = Instruction( jump_table_base = Instruction(
'jump_table_base', r""" 'jump_table_base', r"""

View File

@@ -309,7 +309,8 @@ pub fn define(
"#, "#,
) )
.operands_in(vec![x, addr, Size, JT]) .operands_in(vec![x, addr, Size, JT])
.operands_out(vec![entry]), .operands_out(vec![entry])
.can_load(true),
); );
ig.push( ig.push(

View File

@@ -0,0 +1,29 @@
test licm
target x86_64
function %dont_hoist_jump_table_entry_during_licm() {
jt0 = jump_table [ebb1, ebb1]
ebb0:
fallthrough ebb1
ebb1: ; the loop!
v2 = iconst.i32 42
v3 = ifcmp_imm v2, 0
brif uge v3, ebb1
fallthrough ebb2
ebb2:
v1 = iconst.i32 -14
v8 = ifcmp_imm v1, 2
brif uge v8, ebb1
v5 = jump_table_base.i64 jt0
v6 = jump_table_entry.i64 v1, v5, 4, jt0
v7 = iadd v5, v6
indirect_jump_table_br v7, jt0
; check: ebb2:
; nextln: v8 = ifcmp_imm.i32 v1, 2
; nextln: brif uge v8, ebb1
; nextln: jump_table_entry.i64
}