From d4b0a9f32c68d51f19811baedd10f257fb06752c Mon Sep 17 00:00:00 2001 From: Christian Steinert Date: Mon, 18 Sep 2017 08:32:43 +0200 Subject: [PATCH 1/2] Adds optimized emit for int64 constants. --- src/fsharp/IlxGen.fs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 4fafb20040c..3e491dede93 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2072,7 +2072,13 @@ and GenConstant cenv cgbuf eenv (c,m,ty) sequel = | Const.SByte i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (mkLdcInt32 (int32 i)) | Const.Int16 i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (mkLdcInt32 (int32 i)) | Const.Int32 i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (mkLdcInt32 i) - | Const.Int64 i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (iLdcInt64 i) + | Const.Int64 i -> + if i >= int64 System.Int32.MinValue && i <= int64 System.Int32.MaxValue then + CG.EmitInstrs cgbuf (pop 0) (Push [ilTy]) [ mkLdcInt32 (int32 i); AI_conv DT_I8 ] + elif i >= int64 System.UInt32.MinValue && i <= int64 System.UInt32.MaxValue then + CG.EmitInstrs cgbuf (pop 0) (Push [ilTy]) [ mkLdcInt32 (int32 i); AI_conv DT_U8 ] + else + CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (iLdcInt64 i) | Const.IntPtr i -> CG.EmitInstrs cgbuf (pop 0) (Push [ilTy]) [iLdcInt64 i; AI_conv DT_I ] | Const.Byte i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (mkLdcInt32 (int32 i)) | Const.UInt16 i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (mkLdcInt32 (int32 i)) From d3ee613a1c760b570a6449b24e369e482b29deee Mon Sep 17 00:00:00 2001 From: Christian Steinert Date: Thu, 21 Sep 2017 10:54:51 +0200 Subject: [PATCH 2/2] Adds comment linking to the changing PR. --- src/fsharp/IlxGen.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 3e491dede93..dcc82333144 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2073,6 +2073,7 @@ and GenConstant cenv cgbuf eenv (c,m,ty) sequel = | Const.Int16 i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (mkLdcInt32 (int32 i)) | Const.Int32 i -> CG.EmitInstr cgbuf (pop 0) (Push [ilTy]) (mkLdcInt32 i) | Const.Int64 i -> + // see https://github.com/Microsoft/visualfsharp/pull/3620 if i >= int64 System.Int32.MinValue && i <= int64 System.Int32.MaxValue then CG.EmitInstrs cgbuf (pop 0) (Push [ilTy]) [ mkLdcInt32 (int32 i); AI_conv DT_I8 ] elif i >= int64 System.UInt32.MinValue && i <= int64 System.UInt32.MaxValue then