Skip to content
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

X86 Lea + BitTracker Optimizations #1174

Merged
merged 27 commits into from
Nov 20, 2023
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 23 additions & 2 deletions Source/Data/IR-Optimizations-BitValue.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
"Variations": "No",
"Log": "No"
},
{
"Type": "BitValue",
"Name": "DivSigned##",
"SubName": "ButNotSigned",
"Expression": "IR.DivSigned## a b",
"Filter": "IsBitValueSignBitCleared##(a) && IsBitValueSignBitCleared##(b)",
"Result": "(IR.DivUnsigned## a b)",
"Priority": "20",
"Variations": "No",
"Log": "No"
},
{
"Type": "BitValue",
"Name": "RemSigned##",
Expand All @@ -65,7 +76,6 @@
"Variations": "No",
"Log": "No"
},

{
"Type": "BitValue",
"Name": "Compare##x32Equal",
Expand Down Expand Up @@ -98,7 +108,6 @@
"IR.Compare64x64"
]
},

{
"Type": "BitValue",
"Name": "Compare##x32SignedLess",
Expand Down Expand Up @@ -162,6 +171,18 @@
"IR.Compare64x32",
"IR.Compare64x64"
]
},
{
"Type": "BitValue",
"Name": "AddCarryOut##",
"SubName": "ButNotSigned",
"Expression": "IR.AddCarryOut## a b",
"Filter": "IsBitValueSignBitCleared##(a) && IsBitValueSignBitCleared##(b)",
"Result": "(IR.Add## a b)",
"Result2": "(IR.Move## [To32(0)])",
"Priority": "20",
"Variations": "No",
"Log": "Yes"
}
]
}
66 changes: 60 additions & 6 deletions Source/Data/IR-Optimizations-Simplification.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@
"SubName": "FromShiftedMore32",
"Expression": "IR.GetHigh32 (IR.ShiftRight64 a b)",
"Filter": "IsResolvedConstant(b) && IsGreaterOrEqual(And32(To32(b),63),32)",
"Result": "(IR.Move32 0)"
"Result": "(IR.Move32 [To32(0)])"
},
{
"Type": "Simplification",
"Name": "GetLow32",
"SubName": "FromShiftedMore32",
"Expression": "IR.GetLow32 (IR.ShiftLeft64 a b)",
"Filter": "IsResolvedConstant(b) && IsGreaterOrEqual(And32(To32(b),63),32)",
"Result": "(IR.Move32 0)"
"Result": "(IR.Move32 [To32(0)])"
},
{
"Type": "Simplification",
Expand Down Expand Up @@ -393,7 +393,7 @@
"SubName": "PassThru",
"Expression": "IR.Compare32x## {!=} (IR.And## a 1) 0)",
"Filter": "",
"Result": "(IR.And## a 1)",
"Result": "(IR.And## a [To##(1)])",
"Variations": "Yes"
},
{
Expand All @@ -402,7 +402,7 @@
"SubName": "PassThru",
"Expression": "IR.Compare64x## {!=} (IR.And## a 1) 0)",
"Filter": "",
"Result": "(IR.And## a 1)",
"Result": "(IR.And## a [To##(1)])",
"Variations": "Yes"
},
{
Expand All @@ -429,7 +429,7 @@
"SubName": "PassThru2",
"Expression": "IR.Compare32x## {==} (IR.And## a 1) 1)",
"Filter": "",
"Result": "(IR.And## a 1)",
"Result": "(IR.And## a [To##(1)])",
"Variations": "Yes"
},
{
Expand All @@ -438,7 +438,7 @@
"SubName": "PassThru2",
"Expression": "IR.Compare64x## {==} (IR.And## a 1) 1)",
"Filter": "",
"Result": "(IR.And## a 1)",
"Result": "(IR.And## a [To##(1)])",
"Variations": "Yes"
},
{
Expand Down Expand Up @@ -494,6 +494,60 @@
"Filter": "",
"Result": "(IR.Move## x)",
"Variations": "No"
},
{
"Type": "Simplification",
"Name": "AddCarryOut##",
"SubName": "CarryNotUsed",
"Expression": "IR.AddCarryOut## a b",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Add## a b)",
"Variations": "No"
},
{
"Type": "Simplification",
"Name": "AddOverflowOut##",
"SubName": "OverflowNotUsed",
"Expression": "IR.AddOverflowOut## a b",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Add## a b)",
"Variations": "No"
},
{
"Type": "Simplification",
"Name": "SubCarryOut##",
"SubName": "CarryNotUsed",
"Expression": "IR.SubCarryOut## a b",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Sub## a b)",
"Variations": "No"
},
{
"Type": "Simplification",
"Name": "SubOverflowOut##",
"SubName": "CarryNotUsed",
"Expression": "IR.SubOverflowOut## a b",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Sub## a b)",
"Variations": "No"
},
{
"Type": "Simplification",
"Name": "MulCarryOut##",
"SubName": "CarryNotUsed",
"Expression": "IR.MulCarryOut## a b",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.MulSigned## a b)",
"Variations": "No"
},
{
"Type": "Simplification",
"Name": "MulOverflowOut##",
"SubName": "CarryNotUsed",
"Expression": "IR.MulOverflowOut## a b",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.MulSigned## a b)",
"Variations": "No"
}
]
}
14 changes: 2 additions & 12 deletions Source/Data/IR-Optimizations-StrengthReduction-Complex.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"SubName": "RemUnsigned",
"Expression": "IR.Compare32x## {==} (IR.RemUnsigned## a 2) 0",
"Filter": "",
"Result": "(IR.And## a 1)",
"Result": "(IR.And## a [To##(1)])",
"Variations": "Yes"
},
{
Expand All @@ -47,7 +47,7 @@
"SubName": "RemUnsigned",
"Expression": "IR.Compare64x## {==} (IR.RemUnsigned## a 2) 0",
"Filter": "",
"Result": "(IR.And## a 1)",
"Result": "(IR.And## a [To##(1)])",
"Variations": "Yes"
},
{
Expand Down Expand Up @@ -139,16 +139,6 @@
"Filter": "",
"Result": "(IR.Or## a b)",
"Variations": "Yes"
},
{
"Type": "StrengthReduction",
"Name": "ArithShiftRight64",
"SubName": "By32",
"Expression": "IR.GetLow32 (IR.ArithShiftRight64 (IR.To64 a b) 32)",
"Filter": "",
"Result": "(IR.Move32 b)",
"Variations": "Yes",
"Log": "Yes"
}
]
}
122 changes: 97 additions & 25 deletions Source/Data/IR-Optimizations-StrengthReduction.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"SubName": "Max",
"Expression": "IR.Or64 a 0xFFFFFFFFFFFFFFFF",
"Filter": "",
"Result": "(IR.Move64 0xFFFFFFFFFFFFFFFF)",
"Result": "(IR.Move64 [To64(0xFFFFFFFFFFFFFFFF)])",
"Priority": "80",
"Variations": "Yes"
},
Expand Down Expand Up @@ -220,7 +220,7 @@
"SubName": "Same",
"Expression": "IR.SubManagedPointer a a",
"Filter": "",
"Result": "(IR.MoveManagedPointer [To32(0)])",
"Result": "(IR.MoveManagedPointer 0)",
"Priority": "80"
},
{
Expand Down Expand Up @@ -369,7 +369,7 @@
"SubName": "By32",
"Expression": "IR.ShiftLeft32 x 32",
"Filter": "",
"Result": "(IR.Move32 0)",
"Result": "(IR.Move32 [To32(0)])",
"Priority": "80"
},
{
Expand All @@ -378,16 +378,7 @@
"SubName": "By32",
"Expression": "IR.ShiftRight32 a 32",
"Filter": "",
"Result": "(IR.Move32 0)",
"Priority": "80"
},
{
"Type": "StrengthReduction",
"Name": "ArithShiftRight32",
"SubName": "By32",
"Expression": "IR.ArithShiftRight32 a 32",
"Filter": "",
"Result": "(IR.Move32 0)",
"Result": "(IR.Move32 [To32(0)])",
"Priority": "80"
},
{
Expand All @@ -396,26 +387,16 @@
"SubName": "By64",
"Expression": "IR.ShiftLeft64 x 64",
"Filter": "",
"Result": "(IR.Move64 0)",
"Result": "(IR.Move64 [To64(0)])",
"Priority": "80"
},

{
"Type": "StrengthReduction",
"Name": "ShiftRight64",
"SubName": "By64",
"Expression": "IR.ShiftRight64 a 64",
"Filter": "",
"Result": "(IR.Move64 0)",
"Priority": "80"
},
{
"Type": "StrengthReduction",
"Name": "ArithShiftRight64",
"SubName": "By64",
"Expression": "IR.ArithShiftRight64 a 64",
"Filter": "",
"Result": "(IR.Move64 0)",
"Result": "(IR.Move64 [To64(0)])",
"Priority": "80"
},
{
Expand All @@ -427,6 +408,97 @@
"Result": "(IR.Move32 [To32(0)])",
"Priority": "80",
"Variations": "Yes"
},

{
"Type": "StrengthReduction",
"Name": "AddCarryOut##",
"SubName": "ByZero",
"Expression": "IR.AddCarryOut## a 0",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## a)",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "Yes"
},
{
"Type": "StrengthReduction",
"Name": "AddOverflowOut##",
"SubName": "ByZero",
"Expression": "IR.AddOverflowOut## a 0",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## a)",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "Yes"
},

{
"Type": "StrengthReduction",
"Name": "SubCarryOut##",
"SubName": "ByZero",
"Expression": "IR.SubCarryOut## a 0",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## a)",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "No"
},
{
"Type": "StrengthReduction",
"Name": "SubOverflowOut##",
"SubName": "ByZero",
"Expression": "IR.SubOverflowOut## a 0",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## a)",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "No"
},
{
"Type": "StrengthReduction",
"Name": "MulCarryOut##",
"SubName": "ByOne",
"Expression": "IR.MulCarryOut## a 1",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## a)",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "Yes"
},
{
"Type": "StrengthReduction",
"Name": "MulOverflowOut##",
"SubName": "ByOne",
"Expression": "IR.MulOverflowOut## a 1",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## a)",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "Yes"
},

{
"Type": "StrengthReduction",
"Name": "MulCarryOut##",
"SubName": "ByZero",
"Expression": "IR.MulCarryOut## a 0",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## [To##(0)]))",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "Yes"
},
{
"Type": "StrengthReduction",
"Name": "MulOverflowOut##",
"SubName": "ByZero",
"Expression": "IR.MulOverflowOut## a 0",
"Filter": "!IsResult2Used(@)",
"Result": "(IR.Move## [To##(0)]))",
"Result2": "(IR.Move## [To##(0)])",
"Priority": "80",
"Variations": "Yes"
}
]
}
Loading
Loading