Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Vector<T>.ctor(T val) is not recognized for ubyte/byte/short/ushort when the arg is a local of small int type (e.g. method args).#7683

Merged
sivarv merged 1 commit into
dotnet:masterfrom
sivarv:VectorByteFix
Oct 18, 2016
Merged

Vector<T>.ctor(T val) is not recognized for ubyte/byte/short/ushort when the arg is a local of small int type (e.g. method args).#7683
sivarv merged 1 commit into
dotnet:masterfrom
sivarv:VectorByteFix

Conversation

@sivarv
Copy link
Copy Markdown
Member

@sivarv sivarv commented Oct 18, 2016

Kesteral server constructs Vector<byte> vectors and reported this issue(#7459).

Here is a reduced repro case:

        [MethodImpl(MethodImplOptions.NoInlining)]
        public static Vector<byte> GetVector(byte vectorByte)
        {
            return new Vector<byte>(vectorByte);
        }

IR:

In Compiler::impImportCall: opcode is newobj, kind=0, callRetType is void, structSize is 0
  Known type SIMD Vector<ubyte>
Method .ctor is NOT a SIMD intrinsic
INLINER: during 'impMarkInlineCandidate' result 'failed this callee' reason 'too many il bytes' for 'VectorTest:GetByteVector(ubyte):struct' calling 'System.Numerics.Vector`1[Byte][System.Byte]:.ctor(ubyte):this'

INLINER: Marking System.Numerics.Vector`1[Byte][System.Byte]:.ctor(ubyte):this as NOINLINE because of too many il bytes
INLINER: during 'impMarkInlineCandidate' result 'failed this callee' reason 'too many il bytes'


               [000010] ------------             *  stmtExpr  void  (IL   ???...  ???)
               [000008] --C-G-------             \--*  call      void   System.Numerics.Vector`1[Byte][System.Byte]..ctor
               [000007] L----------- this in rcx    +--*  addr      byref 
               [000006] ------------                |  \--*  lclVar    simd16 V02 loc0         
               [000001] ------------ arg1           \--*  lclVar    ubyte  V01 arg0

Here argType is TYP_UBYTE and expectedArgType is TYP_INT and as a result, .ctor is not recognized as an intrinsic. The fix is that when expected type is given by baseType, use genActualType of argType for comparing against expectedArgType.

Asm diffs across all SIMD tests indicate, even similar issue exists for other small type vectors.
On SSE2 there is 1555 bytes of code size win over 60 methods that got impacted (3.95%).

Fix #7459

@sivarv
Copy link
Copy Markdown
Member Author

sivarv commented Oct 18, 2016

@CarolEidt - please review this.
CC @dotnet/jit-contrib

when the arg is a local of small int type (e.g. method args).
@sivarv
Copy link
Copy Markdown
Member Author

sivarv commented Oct 18, 2016

Updated with formatting changes.

@CarolEidt
Copy link
Copy Markdown

Thanks for fixing this. I was wondering why this wasn't caught by the jitLog testing that I added to the SIMD tests, but it seems that I omitted the non-array .ctors. It would be good to add tests for that - presumably the VectorInit.cs case should be beefed up a bit and add the jitLog testing to it.


In reply to: 254376644 [](ancestors = 254376644)

@CarolEidt
Copy link
Copy Markdown

:shipit:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RyuJIT SIMD: Poor code gen new Vector<byte>(b)

4 participants