-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the register of CAST for contained index operator #74275
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsIf index is contained and the underlying operator is Fixes: #74117
|
20b33ba
to
090091a
Compare
090091a
to
143c749
Compare
@dotnet/jit-contrib |
else if (index->OperIs(GT_CAST)) | ||
{ | ||
index = index->AsCast()->gtGetOp1(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of cast gets here? CAST<long>(int)
? But then what is doing the sign/zero-extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N006 ( 4, 6) [000018] -c--G----U- t18 = * CAST long <- uint $1c0
/--* t19 byref
+--* t18 long
N007 ( 6, 8) [000020] ----------- t20 = * LEA(b+(i*1)+0) byref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so it is indeed CAST<long>(int)
. There is still the question of what is doing the extension (is it perhaps unnecessary)?
@kunalspathak, @dotnet/jit-contrib, are we going to backport it to 7? |
Probably. This issue is around the code that was introduced in .NET 7. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM. We may find out the upfront IsSafeToContainMem
it too expensive TP-wise and will need to move it down after the other checks, but hopefully not.
I've also filed #74448 to track the complete fix, you could add a link to it from codegen (or not).
Also it would be nice to add a regression test, say:
[MethodImpl(MethodImplOptions.NoInlining)]
private static void Problem(ref byte x, int a)
{
[MethodImpl(MethodImplOptions.NoInlining)]
static byte GetByte() => 1;
JitUse(&a);
Unsafe.Add(ref x, a) = GetByte();
}
[MethodImpl(MethodImplOptions.NoInlining)]
public static void JitUse<T>(T* arg) where T : unmanaged { }
This reverts commit e79d17d92ceb0eed5ae1bfd03c2d1d6b171ab17f.
37372b3
to
a6d5919
Compare
@dotnet/jit-contrib - can someone review it? |
@EgorBo - can you take a look? |
oops, sorry for the delay - didn't notice this mention, something is wrong with my mail filters. LGTM btw |
/backport to release/7.0-rc1 |
Started backporting to release/7.0-rc1: https://github.com/dotnet/runtime/actions/runs/2995029976 |
@kunalspathak backporting to release/7.0-rc1 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Rename test files
error: mode change for src/tests/JIT/Regression/JitBlue/Runtime_74373/Runtime_73821.cs, which is not in current HEAD
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Rename test files
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3002058907 |
@kunalspathak backporting to release/7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Rename test files
Applying: Fix index scale for cast
Applying: Do not contain index if indir is not containable.
Applying: Revert "Do not contain index if indir is not containable."
Applying: Instead try to contain the LEA
Using index info to reconstruct a base tree...
M src/coreclr/jit/lower.cpp
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/jit/lower.cpp
CONFLICT (content): Merge conflict in src/coreclr/jit/lower.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0005 Instead try to contain the LEA
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
* Rename test files * Fix index scale for cast * Do not contain index if indir is not containable. * Revert "Do not contain index if indir is not containable." This reverts commit e79d17d92ceb0eed5ae1bfd03c2d1d6b171ab17f. * Instead try to contain the LEA * IsSafeToContainMem() check * Do IsSafeToContainMem() only if needed * Add test case * Fix merge error * fix the test case * review comment
* Rename test files * Fix index scale for cast * Do not contain index if indir is not containable. * Revert "Do not contain index if indir is not containable." This reverts commit e79d17d92ceb0eed5ae1bfd03c2d1d6b171ab17f. * Instead try to contain the LEA * IsSafeToContainMem() check * Do IsSafeToContainMem() only if needed * Add test case * Fix merge error * fix the test case * review comment
If index is contained and the underlying operator is
GT_CAST
we were not handling that case and that led to usingREG_COUNT
register fromindex
ingenScaledAdd()
. I have fixed it and also added checks to see if more such cases are missing.Fixes: #74117