From 7c9b9e3d2758eb4954b17219cf15791a6d357166 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 19 Oct 2017 13:11:33 -0700 Subject: [PATCH] Mark spill and fill as can_store and can_load. This allows GVN to avoid hoisting them. These will be to coarse for things that want more precise dependence information, however we can work that out when we build such things. --- cranelift/filetests/simple_gvn/reject.cton | 15 +++++++++++++++ lib/cretonne/meta/base/instructions.py | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cranelift/filetests/simple_gvn/reject.cton b/cranelift/filetests/simple_gvn/reject.cton index 5544ddbd75..00d88e5e66 100644 --- a/cranelift/filetests/simple_gvn/reject.cton +++ b/cranelift/filetests/simple_gvn/reject.cton @@ -39,3 +39,18 @@ ebb0: ; check: v5 = trueif eq v4 return v6 } + +function %spill() -> i32 { +ebb0: + v0 = iconst.i32 7 + v1 = spill v0 + v2 = fill v1 + v3 = spill v0 + v4 = fill v1 + v5 = bor v2, v4 +; check: v1 = spill v0 +; check: v2 = fill v1 +; check: v3 = spill v0 +; check: v4 = fill v1 + return v5 +} diff --git a/lib/cretonne/meta/base/instructions.py b/lib/cretonne/meta/base/instructions.py index b27a3bf674..f8b6ea989e 100644 --- a/lib/cretonne/meta/base/instructions.py +++ b/lib/cretonne/meta/base/instructions.py @@ -501,7 +501,7 @@ spill = Instruction( This instruction behaves exactly like :inst:`copy`, but the result value is assigned to a spill slot. """, - ins=x, outs=a) + ins=x, outs=a, can_store=True) fill = Instruction( 'fill', r""" @@ -510,7 +510,7 @@ fill = Instruction( This instruction behaves exactly like :inst:`copy`, but creates a new SSA value for the spilled input value. """, - ins=x, outs=a) + ins=x, outs=a, can_load=True) src = Operand('src', regunit) dst = Operand('dst', regunit)