aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/CodeGen/X86/CodeGenerator.cs
diff options
context:
space:
mode:
authorFicture Seven <FICTURE7@gmail.com>2020-07-30 09:52:26 +0400
committerGitHub <noreply@github.com>2020-07-30 15:52:26 +1000
commitb3c051bbec58c667e0e9037c57300791775d84ea (patch)
tree7eb70d9e24b5087ab5828b620578b9889fc97068 /ARMeilleure/CodeGen/X86/CodeGenerator.cs
parent991784868f278b62f7e847321f0cfd7309fe2f79 (diff)
Use movd,movq for i32/64 VectorExtract %x, 0x0 (#1439)
* Use movd,movq for i32/64 VectorExtract %x, 0x0 * Increment PPTC interval version * Use else-if instead - Address gdkchan's feedback. - Clean up Debug.Assert calls * Inline `count` expression into Debug.Assert Apparently the CoreCLR JIT will not eliminate this. :(
Diffstat (limited to 'ARMeilleure/CodeGen/X86/CodeGenerator.cs')
-rw-r--r--ARMeilleure/CodeGen/X86/CodeGenerator.cs56
1 files changed, 23 insertions, 33 deletions
diff --git a/ARMeilleure/CodeGen/X86/CodeGenerator.cs b/ARMeilleure/CodeGen/X86/CodeGenerator.cs
index e217a665..5c9fcd89 100644
--- a/ARMeilleure/CodeGen/X86/CodeGenerator.cs
+++ b/ARMeilleure/CodeGen/X86/CodeGenerator.cs
@@ -1148,62 +1148,52 @@ namespace ARMeilleure.CodeGen.X86
byte index = src2.AsByte();
+ Debug.Assert(index < OperandType.V128.GetSizeInBytes() / dest.Type.GetSizeInBytes());
+
if (dest.Type == OperandType.I32)
{
- Debug.Assert(index < 4);
-
- if (HardwareCapabilities.SupportsSse41)
+ if (index == 0)
+ {
+ context.Assembler.Movd(dest, src1);
+ }
+ else if (HardwareCapabilities.SupportsSse41)
{
context.Assembler.Pextrd(dest, src1, index);
}
else
{
- if (index != 0)
- {
- int mask0 = 0b11_10_01_00;
- int mask1 = 0b11_10_01_00;
+ int mask0 = 0b11_10_01_00;
+ int mask1 = 0b11_10_01_00;
- mask0 = BitUtils.RotateRight(mask0, index * 2, 8);
- mask1 = BitUtils.RotateRight(mask1, 8 - index * 2, 8);
+ mask0 = BitUtils.RotateRight(mask0, index * 2, 8);
+ mask1 = BitUtils.RotateRight(mask1, 8 - index * 2, 8);
- context.Assembler.Pshufd(src1, src1, (byte)mask0);
- context.Assembler.Movd (dest, src1);
- context.Assembler.Pshufd(src1, src1, (byte)mask1);
- }
- else
- {
- context.Assembler.Movd(dest, src1);
- }
+ context.Assembler.Pshufd(src1, src1, (byte)mask0);
+ context.Assembler.Movd (dest, src1);
+ context.Assembler.Pshufd(src1, src1, (byte)mask1);
}
}
else if (dest.Type == OperandType.I64)
{
- Debug.Assert(index < 2);
-
- if (HardwareCapabilities.SupportsSse41)
+ if (index == 0)
+ {
+ context.Assembler.Movq(dest, src1);
+ }
+ else if (HardwareCapabilities.SupportsSse41)
{
context.Assembler.Pextrq(dest, src1, index);
}
else
{
- if (index != 0)
- {
- const byte mask = 0b01_00_11_10;
+ const byte mask = 0b01_00_11_10;
- context.Assembler.Pshufd(src1, src1, mask);
- context.Assembler.Movq (dest, src1);
- context.Assembler.Pshufd(src1, src1, mask);
- }
- else
- {
- context.Assembler.Movq(dest, src1);
- }
+ context.Assembler.Pshufd(src1, src1, mask);
+ context.Assembler.Movq (dest, src1);
+ context.Assembler.Pshufd(src1, src1, mask);
}
}
else
{
- Debug.Assert(index < (dest.Type == OperandType.FP32 ? 4 : 2));
-
// Floating-point types.
if ((index >= 2 && dest.Type == OperandType.FP32) ||
(index == 1 && dest.Type == OperandType.FP64))