Repository navigation
Optimize AdvSimd.Extract() when passed variable that can be const propagated #36070
Description
Activity
- addedarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
on May 7, 2020 - addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on May 7, 2020 //cc : @BruceForstall , @echesakovMSFT , @tannergooding
- removeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on May 7, 2020 cc @CarolEidt
This is a case for any intrinsic that has an immediate operand - not only for Extract
I wonder if it's possible to move an intrinsic call transofrmation from importer to a later phase.Doesn't Roslyn propagate constants for such simple cases (without inlining) ?
This is basically a dupe of #11062 and possibly a couple other issues iirc. It is a problem on both x86/x64 and ARM64.
Ideally we would delay the decision for this to be a call or constant until lowering but that isn't necessarily "easy" to do today.
We already have minimal support for rewriting intrinsics to calls inRationalization(which happens just before lowering) and are using that today forGT_INTRINSIC.We could presumably extend that to
GenTreeJitIntrinsicas well, but it would require a few changes including making it aLARGE_NODE.
I left some comments from my initial investigation here: #11062 (comment) including some of the issues I ran into with theRwriteIntrinsicAsUserCallmethod.Reacted by Kunal PathakThere is also another case that might be related where we miss some optimizations on x86 due to
GT_CASTnodes: #35857 (comment)Basically the tree might look like:
[000038] -----+------ +--* CAST int <- ubyte <- int [000000] -----+------ | \--* LCL_VAR int V01 arg0and certain instructions might be able to contain or consume the underlying value directly, but we aren't smart enough to contain and handle the cast today.
Since it appears unlikely we will work on this for 5.0, I've moved it out to 6.0.
cc @AndyAyersMS who might be interested in the phase ordering aspect of this.
Reacted by Tanner Gooding- addedneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration
on Mar 23, 2021 - addedPriority:3Work that is nice to haveWork that is nice to haveand removedneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration
on Jun 3, 2021 Un-assigning myself
cc @BruceForstallClosing as a dup of #11062
- ghost locked as resolved and limited conversation to collaborators
on Apr 15, 2022
I was expecting it to generate:
But instead we generate the following.
It happens because we decide whether to fallback or not depending on the
indexoperand. If it is const, we generate the optimize code however this decision happens during importing and we won't know if the operand is constant or not until we do constant propagation which is in later phase.We should also investigate if there are more scenarios in which we miss optimizing opportunity because of this dependency and evaluate if we should do the decision after constant propagation is done probably in lower.
category:cq
theme:hardware-intrinsics
skill-level:intermediate
cost:medium