Skip to content

Redefine 'not' to not emit IL directly #9434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fsharp/FSharp.Core/prim-types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3792,7 +3792,7 @@ namespace Microsoft.FSharp.Core
let (|Failure|_|) (error: exn) = if error.GetType().Equals(typeof<System.Exception>) then Some error.Message else None

[<CompiledName("Not")>]
let inline not (value: bool) = (# "ceq" value false : bool #)
let inline not (value: bool) = if value then false else true


let inline (<) x y = GenericLessThan x y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Microsoft (R) .NET Framework IL Disassembler. Version 4.8.3928.0
// Copyright (c) Microsoft Corporation. All rights reserved.


Expand All @@ -13,7 +13,7 @@
.assembly extern FSharp.Core
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:4:1:0
.ver 4:7:0:0
}
.assembly InequalityComparison01
{
Expand All @@ -29,20 +29,20 @@
}
.mresource public FSharpSignatureData.InequalityComparison01
{
// Offset: 0x00000000 Length: 0x0000020E
// Offset: 0x00000000 Length: 0x00000224
}
.mresource public FSharpOptimizationData.InequalityComparison01
{
// Offset: 0x00000218 Length: 0x00000085
// Offset: 0x00000228 Length: 0x00000085
}
.module InequalityComparison01.exe
// MVID: {59B19213-263A-E6D5-A745-03831392B159}
// MVID: {5EE40368-263A-E6D5-A745-03836803E45E}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x002E0000
// Image base: 0x00E80000


// =============== CLASS MEMBERS DECLARATION ===================
Expand All @@ -55,16 +55,34 @@
int32 y) cil managed
{
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
// Code size 24 (0x18)
.maxstack 4
.locals init ([0] int32 V_0,
[1] int32 V_1,
[2] int32 V_2,
[3] int32 V_3,
[4] int32 V_4,
[5] int32 V_5)
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
.line 3,3 : 27,33 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\InequalityComparison\\InequalityComparison01.fs'
.line 3,3 : 27,33 'C:\\Users\\phcart\\source\\repos\\fsharp\\tests\\fsharpqa\\source\\CodeGen\\EmittedIL\\InequalityComparison\\InequalityComparison01.fs'
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: cgt
IL_0004: ldc.i4.0
IL_0005: ceq
IL_0007: ret
IL_0001: stloc.0
IL_0002: ldarg.1
IL_0003: stloc.1
IL_0004: ldloc.0
IL_0005: stloc.2
IL_0006: ldloc.1
IL_0007: stloc.3
IL_0008: ldloc.2
IL_0009: stloc.s V_4
IL_000b: ldloc.3
IL_000c: stloc.s V_5
IL_000e: ldloc.s V_4
IL_0010: ldloc.s V_5
IL_0012: cgt
IL_0014: ldc.i4.0
IL_0015: ceq
IL_0017: ret
} // end of method InequalityComparison01::f1

} // end of class InequalityComparison01
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Microsoft (R) .NET Framework IL Disassembler. Version 4.8.3928.0
// Copyright (c) Microsoft Corporation. All rights reserved.


Expand All @@ -13,7 +13,7 @@
.assembly extern FSharp.Core
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:4:1:0
.ver 4:7:0:0
}
.assembly InequalityComparison02
{
Expand All @@ -29,20 +29,20 @@
}
.mresource public FSharpSignatureData.InequalityComparison02
{
// Offset: 0x00000000 Length: 0x0000020E
// Offset: 0x00000000 Length: 0x00000224
}
.mresource public FSharpOptimizationData.InequalityComparison02
{
// Offset: 0x00000218 Length: 0x00000085
// Offset: 0x00000228 Length: 0x00000085
}
.module InequalityComparison02.exe
// MVID: {59B19213-263A-E72C-A745-03831392B159}
// MVID: {5EE40368-263A-E72C-A745-03836803E45E}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x02D40000
// Image base: 0x00B80000


// =============== CLASS MEMBERS DECLARATION ===================
Expand All @@ -55,16 +55,34 @@
int32 y) cil managed
{
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 )
// Code size 8 (0x8)
.maxstack 8
// Code size 24 (0x18)
.maxstack 4
.locals init ([0] int32 V_0,
[1] int32 V_1,
[2] int32 V_2,
[3] int32 V_3,
[4] int32 V_4,
[5] int32 V_5)
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
.line 3,3 : 27,33 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\InequalityComparison\\InequalityComparison02.fs'
.line 3,3 : 27,33 'C:\\Users\\phcart\\source\\repos\\fsharp\\tests\\fsharpqa\\source\\CodeGen\\EmittedIL\\InequalityComparison\\InequalityComparison02.fs'
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: clt
IL_0004: ldc.i4.0
IL_0005: ceq
IL_0007: ret
IL_0001: stloc.0
IL_0002: ldarg.1
IL_0003: stloc.1
IL_0004: ldloc.0
IL_0005: stloc.2
IL_0006: ldloc.1
IL_0007: stloc.3
IL_0008: ldloc.2
IL_0009: stloc.s V_4
IL_000b: ldloc.3
IL_000c: stloc.s V_5
IL_000e: ldloc.s V_4
IL_0010: ldloc.s V_5
IL_0012: clt
IL_0014: ldc.i4.0
IL_0015: ceq
IL_0017: ret
} // end of method InequalityComparison02::f2

} // end of class InequalityComparison02
Expand Down
39 changes: 22 additions & 17 deletions tests/fsharpqa/Source/CodeGen/EmittedIL/Misc/Seq_for_all01.il.bsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Microsoft (R) .NET Framework IL Disassembler. Version 4.8.3928.0
// Copyright (c) Microsoft Corporation. All rights reserved.


Expand All @@ -13,7 +13,7 @@
.assembly extern FSharp.Core
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:4:1:0
.ver 4:7:0:0
}
.assembly Seq_for_all01
{
Expand All @@ -29,20 +29,20 @@
}
.mresource public FSharpSignatureData.Seq_for_all01
{
// Offset: 0x00000000 Length: 0x000001AB
// Offset: 0x00000000 Length: 0x000001C1
}
.mresource public FSharpOptimizationData.Seq_for_all01
{
// Offset: 0x000001B0 Length: 0x00000072
// Offset: 0x000001C8 Length: 0x00000072
}
.module Seq_for_all01.exe
// MVID: {59B19213-D30D-BA80-A745-03831392B159}
// MVID: {5EE40368-D30D-BA80-A745-03836803E45E}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x02A60000
// Image base: 0x07080000


// =============== CLASS MEMBERS DECLARATION ===================
Expand All @@ -69,28 +69,33 @@
.method public strict virtual instance bool
Invoke(int32 s) cil managed
{
// Code size 14 (0xe)
// Code size 18 (0x12)
.maxstack 8
.language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}'
.line 5,5 : 31,47 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\Misc\\Seq_for_all01.fs'
.line 5,5 : 31,47 'C:\\Users\\phcart\\source\\repos\\fsharp\\tests\\fsharpqa\\source\\CodeGen\\EmittedIL\\Misc\\Seq_for_all01.fs'
IL_0000: ldc.i4.1
IL_0001: brtrue.s IL_0005
IL_0001: ldc.i4.0
IL_0002: ceq
.line 100001,100001 : 0,0 ''
IL_0004: nop
.line 100001,100001 : 0,0 ''
IL_0005: brfalse.s IL_0009

IL_0003: br.s IL_0007
IL_0007: br.s IL_000b

IL_0005: br.s IL_000b
IL_0009: br.s IL_000f

.line 5,5 : 48,50 ''
IL_0007: nop
IL_000b: nop
.line 100001,100001 : 0,0 ''
IL_0008: nop
IL_0009: br.s IL_000c
IL_000c: nop
IL_000d: br.s IL_0010

.line 100001,100001 : 0,0 ''
IL_000b: nop
IL_000f: nop
.line 6,6 : 31,35 ''
IL_000c: ldc.i4.1
IL_000d: ret
IL_0010: ldc.i4.1
IL_0011: ret
} // end of method q@4::Invoke

} // end of class q@4
Expand Down
Loading