diff options
author | Eugene Rozenfeld <erozen@microsoft.com> | 2018-12-19 22:11:27 -0800 |
---|---|---|
committer | Eugene Rozenfeld <erozen@microsoft.com> | 2018-12-21 16:43:30 -0800 |
commit | 6baf0f9d160ad1802f5d8c98d55c44a4550f6119 (patch) | |
tree | 017945baf2c1d2e46eb40348857997c7706f7af0 /src/jit | |
parent | b93891a6e1705f7d8c671cd673abaaf03b0a09cb (diff) | |
download | coreclr-6baf0f9d160ad1802f5d8c98d55c44a4550f6119.tar.gz coreclr-6baf0f9d160ad1802f5d8c98d55c44a4550f6119.tar.bz2 coreclr-6baf0f9d160ad1802f5d8c98d55c44a4550f6119.zip |
Don't mark calls to allocation helpers as CSE candidates.
Marking them as CSE candidates usually blocks CSEs rather than enables them.
A typical case is:
[1] GT_IND(x) = GT_CALL ALLOC_HELPER
...
[2] y = GT_IND(x)
...
[3] z = GT_IND(x)
If we mark CALL ALLOC_HELPER as a CSE candidate, we later discover
that it can't be a CSE def because GT_INDs in [2] and [3] can cause
more exceptions (NullRef) so we abandon this CSE.
If we don't mark CALL ALLOC_HELPER as a CSE candidate, we are able
to use GT_IND(x) in [2] as a CSE def and do a CSE on [2] and [3].
Diffstat (limited to 'src/jit')
-rw-r--r-- | src/jit/optcse.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/jit/optcse.cpp b/src/jit/optcse.cpp index 52157c6479..f578b2aa7e 100644 --- a/src/jit/optcse.cpp +++ b/src/jit/optcse.cpp @@ -2564,6 +2564,29 @@ bool Compiler::optIsCSEcandidate(GenTree* tree) switch (oper) { case GT_CALL: + + GenTreeCall* call; + call = tree->AsCall(); + + // Don't mark calls to allocation helpers as CSE candidates. + // Marking them as CSE candidates usually blocks CSEs rather than enables them. + // A typical case is: + // [1] GT_IND(x) = GT_CALL ALLOC_HELPER + // ... + // [2] y = GT_IND(x) + // ... + // [3] z = GT_IND(x) + // If we mark CALL ALLOC_HELPER as a CSE candidate, we later discover + // that it can't be a CSE def because GT_INDs in [2] and [3] can cause + // more exceptions (NullRef) so we abandon this CSE. + // If we don't mark CALL ALLOC_HELPER as a CSE candidate, we are able + // to use GT_IND(x) in [2] as a CSE def. + if ((call->gtCallType == CT_HELPER) && + s_helperCallProperties.IsAllocator(eeGetHelperNum(call->gtCallMethHnd))) + { + return false; + } + // If we have a simple helper call with no other persistent side-effects // then we allow this tree to be a CSE candidate // |