summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Sullivan <briansul@microsoft.com>2019-04-08 18:04:29 -0700
committerGitHub <noreply@github.com>2019-04-08 18:04:29 -0700
commitcd418635d5db40df67ffb45de74f61ca8df88207 (patch)
tree9ee8e0b6a25597b58fa8cf0b424e0dfd91e41af7 /src
parente8d57987ab738ebaca78b78004a0c6f8b6f373d2 (diff)
parentb87e6349c47b416e571ca905539ea3f6e0554ec7 (diff)
downloadcoreclr-cd418635d5db40df67ffb45de74f61ca8df88207.tar.gz
coreclr-cd418635d5db40df67ffb45de74f61ca8df88207.tar.bz2
coreclr-cd418635d5db40df67ffb45de74f61ca8df88207.zip
Merge pull request #23739 from briansull/struct-cse
Block the hoisting of TYP_STRUCT rvalues in loop hoisting
Diffstat (limited to 'src')
-rw-r--r--src/jit/optimizer.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/jit/optimizer.cpp b/src/jit/optimizer.cpp
index 431f4d5ab1..7749e928ba 100644
--- a/src/jit/optimizer.cpp
+++ b/src/jit/optimizer.cpp
@@ -6885,26 +6885,36 @@ bool Compiler::optHoistLoopExprsForTree(GenTree* tree,
// Tree must be a suitable CSE candidate for us to be able to hoist it.
treeIsHoistable &= optIsCSEcandidate(tree);
- // If it's a call, it must be a helper call, and be pure.
- // Further, if it may run a cctor, it must be labeled as "Hoistable"
- // (meaning it won't run a cctor because the class is not precise-init).
- if (treeIsHoistable && tree->OperGet() == GT_CALL)
+ if (treeIsHoistable)
{
- GenTreeCall* call = tree->AsCall();
- if (call->gtCallType != CT_HELPER)
+ // We cannot hoist an r-value of TYP_STRUCT
+ // as they currently do not carry full descriptors of the struct type
+ if (tree->TypeGet() == TYP_STRUCT)
{
treeIsHoistable = false;
}
- else
+
+ // If it's a call, it must be a helper call, and be pure.
+ // Further, if it may run a cctor, it must be labeled as "Hoistable"
+ // (meaning it won't run a cctor because the class is not precise-init).
+ if (tree->OperGet() == GT_CALL)
{
- CorInfoHelpFunc helpFunc = eeGetHelperNum(call->gtCallMethHnd);
- if (!s_helperCallProperties.IsPure(helpFunc))
+ GenTreeCall* call = tree->AsCall();
+ if (call->gtCallType != CT_HELPER)
{
treeIsHoistable = false;
}
- else if (s_helperCallProperties.MayRunCctor(helpFunc) && (call->gtFlags & GTF_CALL_HOISTABLE) == 0)
+ else
{
- treeIsHoistable = false;
+ CorInfoHelpFunc helpFunc = eeGetHelperNum(call->gtCallMethHnd);
+ if (!s_helperCallProperties.IsPure(helpFunc))
+ {
+ treeIsHoistable = false;
+ }
+ else if (s_helperCallProperties.MayRunCctor(helpFunc) && (call->gtFlags & GTF_CALL_HOISTABLE) == 0)
+ {
+ treeIsHoistable = false;
+ }
}
}
}