From 96217d357f2ed470ff2136bffdc2700ccf21f07b Mon Sep 17 00:00:00 2001 From: Frank Emrich Date: Mon, 15 Mar 2021 23:47:31 +0100 Subject: [PATCH] [compiler] Emit vpbroadcastb for I8x16Splat on x64 if supported Change-Id: Iec90b4821f41838eb4c2bae26035af4e30082ef9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2762140 Reviewed-by: Zhi An Ng Commit-Queue: Frank Emrich Cr-Commit-Position: refs/heads/master@{#73428} --- .../backend/x64/code-generator-x64.cc | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/compiler/backend/x64/code-generator-x64.cc b/src/compiler/backend/x64/code-generator-x64.cc index f8e38939d2..575a15d408 100644 --- a/src/compiler/backend/x64/code-generator-x64.cc +++ b/src/compiler/backend/x64/code-generator-x64.cc @@ -3352,13 +3352,25 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( } case kX64I8x16Splat: { XMMRegister dst = i.OutputSimd128Register(); - if (HasRegisterInput(instr, 0)) { - __ Movd(dst, i.InputRegister(0)); + if (CpuFeatures::IsSupported(AVX2)) { + CpuFeatureScope avx_scope(tasm(), AVX); + CpuFeatureScope avx2_scope(tasm(), AVX2); + if (HasRegisterInput(instr, 0)) { + __ vmovd(kScratchDoubleReg, i.InputRegister(0)); + __ vpbroadcastb(dst, kScratchDoubleReg); + } else { + __ vpbroadcastb(dst, i.InputOperand(0)); + } } else { - __ Movd(dst, i.InputOperand(0)); + if (HasRegisterInput(instr, 0)) { + __ Movd(dst, i.InputRegister(0)); + } else { + __ Movd(dst, i.InputOperand(0)); + } + __ Xorps(kScratchDoubleReg, kScratchDoubleReg); + __ Pshufb(dst, kScratchDoubleReg); } - __ Xorps(kScratchDoubleReg, kScratchDoubleReg); - __ Pshufb(dst, kScratchDoubleReg); + break; } case kX64Pextrb: {