diff options
| author | Ficture Seven <FICTURE7@gmail.com> | 2020-08-05 02:52:33 +0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-05 08:52:33 +1000 |
| commit | ee22517d92c48eab9643b6fc8ce4dac2b7e95f57 (patch) | |
| tree | 5df92a3e83f9daafba44ad11862683af8185ffaf /ARMeilleure/CodeGen/X86/PreAllocator.cs | |
| parent | a33dc2f4919f7fdc8ea9db41c4c70c38cedfd3df (diff) | |
Improve branch operations (#1442)
* Add Compare instruction
* Add BranchIf instruction
* Use test when BranchIf & Compare against 0
* Propagate Compare into BranchIfTrue/False use
- Propagate Compare operations into their BranchIfTrue/False use and
turn these into a BranchIf.
- Clean up Comparison enum.
* Replace BranchIfTrue/False with BranchIf
* Use BranchIf in EmitPtPointerLoad
- Using BranchIf early instead of BranchIfTrue/False improves LCQ and
reduces the amount of work needed by the Optimizer.
EmitPtPointerLoader was a/the big producer of BranchIfTrue/False.
- Fix asserts firing when assembling BitwiseAnd because of type
mismatch in EmitStoreExclusive. This is harmless and should not
cause any diffs.
* Increment PPTC interval version
* Improve IRDumper for BranchIf & Compare
* Use BranchIf in EmitNativeCall
* Clean up
* Do not emit test when immediately preceded by and
Diffstat (limited to 'ARMeilleure/CodeGen/X86/PreAllocator.cs')
| -rw-r--r-- | ARMeilleure/CodeGen/X86/PreAllocator.cs | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/ARMeilleure/CodeGen/X86/PreAllocator.cs b/ARMeilleure/CodeGen/X86/PreAllocator.cs index b76e9416..2f430b6f 100644 --- a/ARMeilleure/CodeGen/X86/PreAllocator.cs +++ b/ARMeilleure/CodeGen/X86/PreAllocator.cs @@ -154,7 +154,7 @@ namespace ARMeilleure.CodeGen.X86 // -- Doing so may allow us to encode the constant as operand 2 and avoid a copy. // - If the constant is on operand 2, we check if the instruction supports it, // if not, we also add a copy. 64-bits constants are usually not supported. - if (IsCommutative(inst)) + if (IsCommutative(operation)) { src2 = operation.GetSource(1); @@ -1348,16 +1348,8 @@ namespace ARMeilleure.CodeGen.X86 case Instruction.BitwiseAnd: case Instruction.BitwiseExclusiveOr: case Instruction.BitwiseOr: - case Instruction.CompareEqual: - case Instruction.CompareGreater: - case Instruction.CompareGreaterOrEqual: - case Instruction.CompareGreaterOrEqualUI: - case Instruction.CompareGreaterUI: - case Instruction.CompareLess: - case Instruction.CompareLessOrEqual: - case Instruction.CompareLessOrEqualUI: - case Instruction.CompareLessUI: - case Instruction.CompareNotEqual: + case Instruction.BranchIf: + case Instruction.Compare: case Instruction.Multiply: case Instruction.RotateRight: case Instruction.ShiftLeft: @@ -1376,18 +1368,28 @@ namespace ARMeilleure.CodeGen.X86 return false; } - private static bool IsCommutative(Instruction inst) + private static bool IsCommutative(Operation operation) { - switch (inst) + switch (operation.Instruction) { case Instruction.Add: case Instruction.BitwiseAnd: case Instruction.BitwiseExclusiveOr: case Instruction.BitwiseOr: - case Instruction.CompareEqual: - case Instruction.CompareNotEqual: case Instruction.Multiply: return true; + + case Instruction.BranchIf: + case Instruction.Compare: + { + Operand comp = operation.GetSource(2); + + Debug.Assert(comp.Kind == OperandKind.Constant); + + var compType = (Comparison)comp.AsInt32(); + + return compType == Comparison.Equal || compType == Comparison.NotEqual; + } } return false; |
