From 412db846f35004fa3d7d951ba252ad6d1f234a1d Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 24 Jan 2021 18:58:37 +0300 Subject: [PATCH 01/10] Fix logic to check that all bits are either set or unset in a constant vector --- src/coreclr/jit/lowerxarch.cpp | 12 +- .../Regression/GitHub_47236/GitHub_47236.cs | 175 ++++++++++++++++++ .../GitHub_47236/GitHub_47236.csproj | 12 ++ 3 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.cs create mode 100644 src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.csproj diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index a1211814951357..4de6384148f44c 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1517,8 +1517,16 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32)); - if ((argCnt == 1) || - ((vecCns.i64[0] == vecCns.i64[1]) && ((simdSize <= 16) || (vecCns.i64[2] == vecCns.i64[3])))) + bool allBytesAreSame = true; + for (UINT32 i = 0; i < simdSize; i++) + { + if (vecCns.i8[i] != vecCns.i8[0]) + { + allBytesAreSame = false; + } + } + + if ((argCnt == 1) || allBytesAreSame) { // If we are a single constant or if all parts are the same, we might be able to optimize // this even further for certain values, such as Zero or AllBitsSet. diff --git a/src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.cs b/src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.cs new file mode 100644 index 00000000000000..6f18bcc57ffd58 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.cs @@ -0,0 +1,175 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; + +public static class Program +{ + private static int s_returnCode = 100; + + public static int Main(string[] args) + { + TestVector256(); + TestVector128(); + TestVector64(); + return s_returnCode; + } + + public static void TestVector256() + { + // Test get_Zero() optimization: + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 1>", Vector256.Create(0, 0, 0, 0, 0, 0, 0, 1).ToString()); + Assert("<0, 0, 0, 0, 1, 1, 1, 1>", Vector256.Create(0, 0, 0, 0, 1, 1, 1, 1).ToString()); + Assert("<0, 0, 0, 1, 1, 1, 1, 1>", Vector256.Create(0, 0, 0, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(0, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 0, 0, 0, 0>", Vector256.Create(1, 1, 1, 1, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0>", Vector256.Create(0, 0, 0, 0).ToString()); + Assert("<0, 0, 1, 1>", Vector256.Create(0, 0, 1, 1).ToString()); + Assert("<0, 1, 1, 1>", Vector256.Create(0, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1).ToString()); + Assert("<1, 1, 0, 0>", Vector256.Create(1, 1, 0, 0).ToString()); + + // Test get_AllBitSet() optimization: + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, 1>", Vector256.Create(-1, -1, -1, -1, -1, -1, -1, 1).ToString()); + Assert("<-1, -1, -1, -1, 1, 1, 1, 1>", Vector256.Create(-1, -1, -1, -1, 1, 1, 1, 1).ToString()); + Assert("<-1, -1, -1, 1, 1, 1, 1, 1>", Vector256.Create(-1, -1, -1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(-1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, -1, -1, -1, -1>", Vector256.Create(1, 1, 1, 1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1>", Vector256.Create(-1, -1, -1, -1).ToString()); + Assert("<-1, -1, 1, 1>", Vector256.Create(-1, -1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1>", Vector256.Create(-1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1>", Vector256.Create(1, 1, 1, 1).ToString()); + Assert("<1, 1, -1, -1>", Vector256.Create(1, 1, -1, -1).ToString()); + } + + public static void TestVector128() + { + // Test get_Zero() optimization: + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>", Vector128.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1>", Vector128.Create(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0>", Vector128.Create(1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 0>", Vector128.Create(0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 1>", Vector128.Create(0, 0, 0, 0, 0, 0, 0, 1).ToString()); + Assert("<0, 0, 0, 0, 1, 1, 1, 1>", Vector128.Create(0, 0, 0, 0, 1, 1, 1, 1).ToString()); + Assert("<0, 0, 0, 1, 1, 1, 1, 1>", Vector128.Create(0, 0, 0, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(0, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 0, 0, 0, 0>", Vector128.Create(1, 1, 1, 1, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0>", Vector128.Create(0, 0, 0, 0).ToString()); + Assert("<0, 0, 1, 1>", Vector128.Create(0, 0, 1, 1).ToString()); + Assert("<0, 1, 1, 1>", Vector128.Create(0, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1>", Vector128.Create(1, 1, 1, 1).ToString()); + Assert("<1, 1, 0, 0>", Vector128.Create(1, 1, 0, 0).ToString()); + Assert("<0, 0>", Vector128.Create(0, 0).ToString()); + Assert("<0, 1>", Vector128.Create(0, 1).ToString()); + Assert("<1, 1>", Vector128.Create(1, 1).ToString()); + Assert("<1, 0>", Vector128.Create(1, 0).ToString()); + + // Test get_AllBitSet() optimization: + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1>", Vector128.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1>", Vector128.Create(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(-1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(-1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1>", Vector128.Create(1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, -1>", Vector128.Create(-1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, 1>", Vector128.Create(-1, -1, -1, -1, -1, -1, -1, 1).ToString()); + Assert("<-1, -1, -1, -1, 1, 1, 1, 1>", Vector128.Create(-1, -1, -1, -1, 1, 1, 1, 1).ToString()); + Assert("<-1, -1, -1, 1, 1, 1, 1, 1>", Vector128.Create(-1, -1, -1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(-1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1>", Vector128.Create(1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, -1, -1, -1, -1>", Vector128.Create(1, 1, 1, 1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1>", Vector128.Create(-1, -1, -1, -1).ToString()); + Assert("<-1, -1, 1, 1>", Vector128.Create(-1, -1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1>", Vector128.Create(-1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1>", Vector128.Create(1, 1, 1, 1).ToString()); + Assert("<1, 1, -1, -1>", Vector128.Create(1, 1, -1, -1).ToString()); + Assert("<-1, -1>", Vector128.Create(-1, -1).ToString()); + Assert("<-1, 1>", Vector128.Create(-1, 1).ToString()); + Assert("<1, -1>", Vector128.Create(1, -1).ToString()); + } + + public static void TestVector64() + { + // Test get_Zero() optimization: + Assert("<0, 0, 0, 0, 0, 0, 0, 0>", Vector64.Create(0, 0, 0, 0, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0, 0, 0, 0, 1>", Vector64.Create(0, 0, 0, 0, 0, 0, 0, 1).ToString()); + Assert("<0, 0, 0, 0, 1, 1, 1, 1>", Vector64.Create(0, 0, 0, 0, 1, 1, 1, 1).ToString()); + Assert("<0, 0, 0, 1, 1, 1, 1, 1>", Vector64.Create(0, 0, 0, 1, 1, 1, 1, 1).ToString()); + Assert("<0, 1, 1, 1, 1, 1, 1, 1>", Vector64.Create(0, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1>", Vector64.Create(1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 0, 0, 0, 0>", Vector64.Create(1, 1, 1, 1, 0, 0, 0, 0).ToString()); + Assert("<0, 0, 0, 0>", Vector64.Create(0, 0, 0, 0).ToString()); + Assert("<0, 0, 1, 1>", Vector64.Create(0, 0, 1, 1).ToString()); + Assert("<0, 1, 1, 1>", Vector64.Create(0, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1>", Vector64.Create(1, 1, 1, 1).ToString()); + Assert("<1, 1, 0, 0>", Vector64.Create(1, 1, 0, 0).ToString()); + Assert("<0, 0>", Vector64.Create(0, 0).ToString()); + Assert("<0, 1>", Vector64.Create(0, 1).ToString()); + Assert("<1, 1>", Vector64.Create(1, 1).ToString()); + Assert("<1, 0>", Vector64.Create(1, 0).ToString()); + + // Test get_AllBitSet() optimization: + Assert("<-1, -1, -1, -1, -1, -1, -1, -1>", Vector64.Create(-1, -1, -1, -1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1, -1, -1, -1, 1>", Vector64.Create(-1, -1, -1, -1, -1, -1, -1, 1).ToString()); + Assert("<-1, -1, -1, -1, 1, 1, 1, 1>", Vector64.Create(-1, -1, -1, -1, 1, 1, 1, 1).ToString()); + Assert("<-1, -1, -1, 1, 1, 1, 1, 1>", Vector64.Create(-1, -1, -1, 1, 1, 1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1, 1, 1, 1, 1>", Vector64.Create(-1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, 1, 1, 1, 1>", Vector64.Create(1, 1, 1, 1, 1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1, -1, -1, -1, -1>", Vector64.Create(1, 1, 1, 1, -1, -1, -1, -1).ToString()); + Assert("<-1, -1, -1, -1>", Vector64.Create(-1, -1, -1, -1).ToString()); + Assert("<-1, -1, 1, 1>", Vector64.Create(-1, -1, 1, 1).ToString()); + Assert("<-1, 1, 1, 1>", Vector64.Create(-1, 1, 1, 1).ToString()); + Assert("<1, 1, 1, 1>", Vector64.Create(1, 1, 1, 1).ToString()); + Assert("<1, 1, -1, -1>", Vector64.Create(1, 1, -1, -1).ToString()); + Assert("<-1, -1>", Vector64.Create(-1, -1).ToString()); + Assert("<-1, 1>", Vector64.Create(-1, 1).ToString()); + Assert("<1, -1>", Vector64.Create(1, -1).ToString()); + } + + private static void Assert(string expected, string actual, [CallerLineNumber] int line = 0) + { + if (expected != actual) + { + s_returnCode++; + Console.WriteLine($"{expected} != {actual}, L{line}"); + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.csproj b/src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.csproj new file mode 100644 index 00000000000000..56a11ebad2333c --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/General/Regression/GitHub_47236/GitHub_47236.csproj @@ -0,0 +1,12 @@ + + + Exe + + + Embedded + True + + + + + From 7f6fc184cb2b907522579d42ac62e2fcb878f04c Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 24 Jan 2021 19:16:27 +0300 Subject: [PATCH 02/10] Address feedback --- src/coreclr/jit/lowerxarch.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 4de6384148f44c..e761b1a24e2cfa 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1517,16 +1517,16 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32)); - bool allBytesAreSame = true; - for (UINT32 i = 0; i < simdSize; i++) + bool i64ComponentsEqual = true; + for (UINT32 i = 0; i < simdSize / 8; i++) { - if (vecCns.i8[i] != vecCns.i8[0]) + if (vecCns.i64[i] != vecCns.i64[0]) { - allBytesAreSame = false; + i64ComponentsEqual = false; } } - if ((argCnt == 1) || allBytesAreSame) + if ((argCnt == 1) || i64ComponentsEqual) { // If we are a single constant or if all parts are the same, we might be able to optimize // this even further for certain values, such as Zero or AllBitsSet. From a1a0ecfc905143dcb0a626674822173a0cb26b0d Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 24 Jan 2021 22:18:59 +0300 Subject: [PATCH 03/10] Ignore tests on Mono --- src/tests/issues.targets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index aa5a4c9ef356b2..6d027edf04f543 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -979,6 +979,9 @@ https://github.com/dotnet/runtime/issues/43676 + + https://github.com/dotnet/runtime/issues/47236 + Tests features specific to coreclr From 0a224e7124c7df04507be5cbcd3279d810072343 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sun, 24 Jan 2021 22:28:44 +0300 Subject: [PATCH 04/10] Update issues.targets --- src/tests/issues.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 6d027edf04f543..45d67600191b2a 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -980,7 +980,7 @@ https://github.com/dotnet/runtime/issues/43676 - https://github.com/dotnet/runtime/issues/47236 + https://github.com/dotnet/runtime/issues/43676 Tests features specific to coreclr From 741a435ada64ebf3e6bfdbd7ded5616b6ae09dd7 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 1 Feb 2021 14:35:50 +0300 Subject: [PATCH 05/10] Fix simd12 case --- src/coreclr/jit/lowerxarch.cpp | 51 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index d80a541508d0d5..5723ba9382dad7 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1517,36 +1517,41 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32)); - bool i64ComponentsEqual = true; - for (UINT32 i = 0; i < simdSize / 8; i++) - { - if (vecCns.i64[i] != vecCns.i64[0]) + bool allBitsAreUnset = true; + bool allBitsAreSet = true; + int i32ComponentsToInspect = argCnt == 1 ? 2 : simdSize / 4; + // Inspect only first two 32bit components if argCnt == 1 + // or simdSize / 4 otherwise (32bit is the greatest common factor). + for (int i = 0; i < i32ComponentsToInspect; i++) + { + if (vecCns.i32[i] != 0) + { + allBitsAreUnset = false; + } + else if (vecCns.i32[i] != -1) { - i64ComponentsEqual = false; + allBitsAreSet = false; } } - if ((argCnt == 1) || i64ComponentsEqual) - { - // If we are a single constant or if all parts are the same, we might be able to optimize - // this even further for certain values, such as Zero or AllBitsSet. + // If we are a single constant or if all parts are the same, we might be able to optimize + // this even further for certain values, such as Zero or AllBitsSet. - if (vecCns.i64[0] == 0) - { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; + if (allBitsAreUnset) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_Zero; - return; - } - else if (vecCns.i64[0] == -1) - { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; + node->gtHWIntrinsicId = NI_Vector128_get_Zero; + return; + } + else if (allBitsAreSet) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet; - return; - } + node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet; + return; } unsigned cnsSize = (simdSize != 12) ? simdSize : 16; From e384c84805755e29b91732b5191e9d22dcebf390 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Tue, 2 Feb 2021 11:51:23 +0300 Subject: [PATCH 06/10] Fix arm64 issue --- src/coreclr/jit/lowerarmarch.cpp | 18 +++++++++++++-- src/coreclr/jit/lowerxarch.cpp | 39 ++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 80e2bc2c5db81a..c510e412a3c09c 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -976,17 +976,31 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) if (vecCns.i64[0] == 0) { + if (simdSize == 8) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; + node->gtHWIntrinsicId = NI_Vector64_get_Zero; + return; + } + assert(simdSize == 16); node->gtOp1 = nullptr; node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_Zero; return; } else if (vecCns.i64[0] == -1) { + if (simdSize == 8) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; + node->gtHWIntrinsicId = NI_Vector64_get_AllBitsSet; + return; + } + assert(simdSize == 16); node->gtOp1 = nullptr; node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet; return; } diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 5723ba9382dad7..c7ee1e06aeb31c 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1516,6 +1516,7 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) } assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32)); + assert(simdSize % 4 == 0); bool allBitsAreUnset = true; bool allBitsAreSet = true; @@ -1539,19 +1540,37 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) if (allBitsAreUnset) { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; - - node->gtHWIntrinsicId = NI_Vector128_get_Zero; - return; + if (simdSize == 16) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; + node->gtHWIntrinsicId = NI_Vector128_get_Zero; + return; + } + else if (simdSize == 32) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; + node->gtHWIntrinsicId = NI_Vector256_get_Zero; + return; + } } else if (allBitsAreSet) { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; - - node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet; - return; + if (simdSize == 16) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; + node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet; + return; + } + else if (simdSize == 32) + { + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; + node->gtHWIntrinsicId = NI_Vector256_get_AllBitsSet; + return; + } } unsigned cnsSize = (simdSize != 12) ? simdSize : 16; From 94759073064d3b116c59c11f41b0213244ec9c47 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Tue, 2 Feb 2021 12:26:07 +0300 Subject: [PATCH 07/10] Clean up --- src/coreclr/jit/lower.h | 22 ++++++++++++++ src/coreclr/jit/lowerarmarch.cpp | 22 ++------------ src/coreclr/jit/lowerxarch.cpp | 50 +++++--------------------------- 3 files changed, 33 insertions(+), 61 deletions(-) diff --git a/src/coreclr/jit/lower.h b/src/coreclr/jit/lower.h index c8500c0636b92b..bb55e5532e9b11 100644 --- a/src/coreclr/jit/lower.h +++ b/src/coreclr/jit/lower.h @@ -348,6 +348,28 @@ class Lowering final : public Phase double f64[4]; }; + //---------------------------------------------------------------------------------------------- + // VectorConstantIsBroadcastedI64: Check N i64 elements in a constant vector for equality + // + // Arguments: + // vecCns - Constant vector + // count - Amount of i64 components to compare + // + // Returns: + // true if N i64 elements of the given vector are equal + static bool VectorConstantIsBroadcastedI64(VectorConstant& vecCns, int count) + { + assert(count >= 1 && count <= 4); + for (int i = 0; i < count; i++) + { + if (vecCns.i64[i] != vecCns.i64[0]) + { + return false; + } + } + return true; + } + //---------------------------------------------------------------------------------------------- // ProcessArgForHWIntrinsicCreate: Processes an argument for the Lowering::LowerHWIntrinsicCreate method // diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index c510e412a3c09c..70d5b4b5b6a9b1 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -969,39 +969,23 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 16)); - if ((argCnt == 1) || (simdSize == 8) || (vecCns.i64[0] == vecCns.i64[1])) + if (VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1 ? argCnt : simdSize / 8))) { // If we are a single constant or if all parts are the same, we might be able to optimize // this even further for certain values, such as Zero or AllBitsSet. if (vecCns.i64[0] == 0) { - if (simdSize == 8) - { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector64_get_Zero; - return; - } - assert(simdSize == 16); node->gtOp1 = nullptr; node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_Zero; + node->gtHWIntrinsicId = (simdSize == 8) ? NI_Vector64_get_Zero : NI_Vector128_get_Zero; return; } else if (vecCns.i64[0] == -1) { - if (simdSize == 8) - { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector64_get_AllBitsSet; - return; - } - assert(simdSize == 16); node->gtOp1 = nullptr; node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet; + node->gtHWIntrinsicId = (simdSize == 8) ? NI_Vector64_get_AllBitsSet : NI_Vector128_get_AllBitsSet; return; } } diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index c7ee1e06aeb31c..4a2c52863399c2 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1516,59 +1516,25 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) } assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32)); - assert(simdSize % 4 == 0); - bool allBitsAreUnset = true; - bool allBitsAreSet = true; - int i32ComponentsToInspect = argCnt == 1 ? 2 : simdSize / 4; - // Inspect only first two 32bit components if argCnt == 1 - // or simdSize / 4 otherwise (32bit is the greatest common factor). - for (int i = 0; i < i32ComponentsToInspect; i++) + if (((simdSize == 16) || (simdSize == 32)) && + VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1 ? argCnt : simdSize / 8))) { - if (vecCns.i32[i] != 0) - { - allBitsAreUnset = false; - } - else if (vecCns.i32[i] != -1) - { - allBitsAreSet = false; - } - } + // If we are a single constant or if all parts are the same, we might be able to optimize + // this even further for certain values, such as Zero or AllBitsSet. - // If we are a single constant or if all parts are the same, we might be able to optimize - // this even further for certain values, such as Zero or AllBitsSet. - - if (allBitsAreUnset) - { - if (simdSize == 16) - { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_Zero; - return; - } - else if (simdSize == 32) - { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector256_get_Zero; - return; - } - } - else if (allBitsAreSet) - { - if (simdSize == 16) + if (vecCns.i64[0] == 0) { node->gtOp1 = nullptr; node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector128_get_AllBitsSet; + node->gtHWIntrinsicId = (simdSize == 16) ? NI_Vector128_get_Zero : NI_Vector256_get_Zero; return; } - else if (simdSize == 32) + else if (vecCns.i64[0] == -1) { node->gtOp1 = nullptr; node->gtOp2 = nullptr; - node->gtHWIntrinsicId = NI_Vector256_get_AllBitsSet; + node->gtHWIntrinsicId = (simdSize == 16) ? NI_Vector128_get_AllBitsSet : NI_Vector256_get_AllBitsSet; return; } } From f63d2b1f1d66a9596c35905e8ef7e8cbabd0ea6b Mon Sep 17 00:00:00 2001 From: EgorBo Date: Tue, 2 Feb 2021 13:26:53 +0300 Subject: [PATCH 08/10] Formatting --- src/coreclr/jit/lowerarmarch.cpp | 10 +++++----- src/coreclr/jit/lowerxarch.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 70d5b4b5b6a9b1..07cef74d1212b7 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -969,22 +969,22 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 16)); - if (VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1 ? argCnt : simdSize / 8))) + if (VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1) ? argCnt : (simdSize / 8))) { // If we are a single constant or if all parts are the same, we might be able to optimize // this even further for certain values, such as Zero or AllBitsSet. if (vecCns.i64[0] == 0) { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; node->gtHWIntrinsicId = (simdSize == 8) ? NI_Vector64_get_Zero : NI_Vector128_get_Zero; return; } else if (vecCns.i64[0] == -1) { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; node->gtHWIntrinsicId = (simdSize == 8) ? NI_Vector64_get_AllBitsSet : NI_Vector128_get_AllBitsSet; return; } diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 4a2c52863399c2..2cac4097e868ce 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1518,22 +1518,22 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32)); if (((simdSize == 16) || (simdSize == 32)) && - VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1 ? argCnt : simdSize / 8))) + VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1) ? argCnt : (simdSize / 8))) { // If we are a single constant or if all parts are the same, we might be able to optimize // this even further for certain values, such as Zero or AllBitsSet. if (vecCns.i64[0] == 0) { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; node->gtHWIntrinsicId = (simdSize == 16) ? NI_Vector128_get_Zero : NI_Vector256_get_Zero; return; } else if (vecCns.i64[0] == -1) { - node->gtOp1 = nullptr; - node->gtOp2 = nullptr; + node->gtOp1 = nullptr; + node->gtOp2 = nullptr; node->gtHWIntrinsicId = (simdSize == 16) ? NI_Vector128_get_AllBitsSet : NI_Vector256_get_AllBitsSet; return; } From 86996ba6cd9c2def14be43779c22b791dc5dc71d Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Fri, 12 Feb 2021 22:17:13 +0300 Subject: [PATCH 09/10] Update src/coreclr/jit/lower.h Co-authored-by: Sergey Andreenko --- src/coreclr/jit/lower.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/lower.h b/src/coreclr/jit/lower.h index bb55e5532e9b11..83ce67d2685ddc 100644 --- a/src/coreclr/jit/lower.h +++ b/src/coreclr/jit/lower.h @@ -360,7 +360,7 @@ class Lowering final : public Phase static bool VectorConstantIsBroadcastedI64(VectorConstant& vecCns, int count) { assert(count >= 1 && count <= 4); - for (int i = 0; i < count; i++) + for (int i = 1; i < count; i++) { if (vecCns.i64[i] != vecCns.i64[0]) { From 74dd162d75ad1419d79993b90038e7222f4616e3 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Tue, 16 Feb 2021 18:35:51 +0300 Subject: [PATCH 10/10] Address Sergey's feedback --- src/coreclr/jit/lowerarmarch.cpp | 2 +- src/coreclr/jit/lowerxarch.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/lowerarmarch.cpp b/src/coreclr/jit/lowerarmarch.cpp index 07cef74d1212b7..432defc06e5bd2 100644 --- a/src/coreclr/jit/lowerarmarch.cpp +++ b/src/coreclr/jit/lowerarmarch.cpp @@ -969,7 +969,7 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 16)); - if (VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1) ? argCnt : (simdSize / 8))) + if (VectorConstantIsBroadcastedI64(vecCns, simdSize / 8)) { // If we are a single constant or if all parts are the same, we might be able to optimize // this even further for certain values, such as Zero or AllBitsSet. diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 2cac4097e868ce..98aa897960009c 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1517,8 +1517,7 @@ void Lowering::LowerHWIntrinsicCreate(GenTreeHWIntrinsic* node) assert((simdSize == 8) || (simdSize == 12) || (simdSize == 16) || (simdSize == 32)); - if (((simdSize == 16) || (simdSize == 32)) && - VectorConstantIsBroadcastedI64(vecCns, (argCnt == 1) ? argCnt : (simdSize / 8))) + if (((simdSize == 16) || (simdSize == 32)) && VectorConstantIsBroadcastedI64(vecCns, simdSize / 8)) { // If we are a single constant or if all parts are the same, we might be able to optimize // this even further for certain values, such as Zero or AllBitsSet.