Uh oh!
There was an error while loading. Please reload this page.
Optimize Vector128/256.Equals via TestZ - #55875
Conversation
MichalPetryka
commented
Jul 17, 2021
Partially fixes #55343 since that also talks about optimizing AllBitsSet to a TestC. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
EgorBo
commented
Jul 23, 2021
@tannergooding @dotnet/jit-contrib does it look good? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Tanner Gooding <tagoo@outlook.com>
… into opt-vector-create
@dotnet/jit-contrib PTAL, a small improvement for Vector128/256.Create Failed CI job is unrelated (broken gcc build) |
| GenTree* op2 = hw->gtGetOp2(); | ||
| if (!gtIsActiveCSE_Candidate(tree)) | ||
| { | ||
| if (op1->IsIntegralConstVector(0) && !gtIsActiveCSE_Candidate(op1)) |
There was a problem hiding this comment.
I think that IsIntegralConstVector will only work for integer vectors, so all floating point vectors will be rejected here.
There was a problem hiding this comment.
Xor is not used in Equals for floats and doubles so it's not a big deal
but it currently handles this (Xor for floats) just fine:
staticVector128<float>Foo(Vector128<float>v)=>Sse.Xor(v,Vector128.Create(0).AsSingle());There was a problem hiding this comment.
for zero float it might be tricky as e.g. -0.0 can't be used in this optimization so is not worth the effort
There was a problem hiding this comment.
Why would it be tricky? You can account for -0.0 by checking the bitwise (rather than floating-point) value is 0.
Speaking of 0.0 vs -0.0, it looks like there might be existing bugs in IsFPZero and IsSIMDZero since they don't take this into account.
BruceForstall
left a comment
There was a problem hiding this comment.
LGTM. But would like @tannergooding to also approve.
EgorBo
commented
Sep 23, 2021
@tannergooding PTAL |
| } | ||
| #endif | ||
| // TODO: Enable substitution for CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE (typeof(T)) |
There was a problem hiding this comment.
Do we have an existing issue for this TODO?
There was a problem hiding this comment.
That's why I want to merge it - to start experimenting with it 🙂 the issue is #40381
There was a problem hiding this comment.
Thanks. I just wanted to make sure we had some github issue corresponding to the TODO, so its not just a comment we'll forget about
tannergooding
left a comment
There was a problem hiding this comment.
Changes LGTM. Would be good to ensure floating-point is equally well handled.
This PR optimizes Vector128/256.Equals via the following improvements:
Xor(x, zero)to justxin morphCodegen diff: https://www.diffchecker.com/zJhfk9yq
According to benchmarks, it makes it 10-15% faster
jit-diff is quite small:
Superpmi: