dotnet / dotnet/runtime

ARM64: bad codegen for Vector.Dot

Open
#132,800 1 comment 0 reactions 1 assignee Claimed by @dhartglassMSFT View on GitHub
area-CodeGen-coreclr
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

The following code returns a different value under jit optimizations on arm64:
```
public static int Main()
{
int result = Vector128.IndexOf(
AdvSimd.SubtractRoundedHighNarrowingUpper(Vector64.AllBitsSet,
Vector128.AllBitsSet,
Vector128.AllBitsSet),
Vector.Dot(Vector.One, Vector.One));

return result == -1 ? 100 : 101;
}
```

jit generates CMEQ for Vector IndexOf which expects the dot product in every lane.
Lowering for this Vector.Dot uses AddAcross (ADDV) which writes to only lane 0.
Either we shouldn't have dropped the toScalar+Create during Morph, or lower must explicitly broadcast as well.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.