From 429fbddedae1bc7f9d7327ca0f68dd27841dc9c0 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Wed, 16 Oct 2019 05:22:45 -0700 Subject: [PATCH] [sledge] Refine inlining heuristic to allow casts Summary: To avoid code explosion, the frontend emits move instructions for expressions with more than one use. This diff relaxes this slightly by allowing duplication of casts. Reviewed By: bennostein Differential Revision: D17856384 fbshipit-source-id: 6f6c496ef --- sledge/src/llair/frontend.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sledge/src/llair/frontend.ml b/sledge/src/llair/frontend.ml index bfa638572..f967f9dd9 100644 --- a/sledge/src/llair/frontend.ml +++ b/sledge/src/llair/frontend.ml @@ -324,7 +324,14 @@ let should_inline : Llvm.llvalue -> bool = match Llvm.use_begin llv with | Some use -> ( match Llvm.use_succ use with - | Some _ -> false (* do not inline if >= 2 uses *) + | Some _ -> ( + match Llvm.classify_value llv with + | Instruction + ( Trunc | ZExt | SExt | FPToUI | FPToSI | UIToFP | SIToFP + | FPTrunc | FPExt | PtrToInt | IntToPtr | BitCast | AddrSpaceCast + ) -> + true (* inline casts *) + | _ -> false (* do not inline if >= 2 uses *) ) | None -> true ) | None -> true