@@ -499,26 +499,11 @@ unsigned optCSEKeyToHashIndex(size_t key, size_t optCSEhashSize)
499499//
500500unsigned Compiler::optValnumCSE_Index (GenTree* tree, Statement* stmt)
501501{
502- size_t key;
503- unsigned hval;
504- CSEdsc* hashDsc;
505- bool enableSharedConstCSE = false ;
506- bool isSharedConst = false ;
507- int configValue = JitConfig.JitConstCSE ();
508-
509- #if defined(TARGET_ARMARCH)
510- // ARMARCH - allow to combine with nearby offsets, when config is not 2 or 4
511- if ((configValue != CONST_CSE_ENABLE_ARM_NO_SHARING) && (configValue != CONST_CSE_ENABLE_ALL_NO_SHARING))
512- {
513- enableSharedConstCSE = true ;
514- }
515- #endif // TARGET_ARMARCH
516-
517- // All Platforms - also allow to combine with nearby offsets, when config is 3
518- if (configValue == CONST_CSE_ENABLE_ALL)
519- {
520- enableSharedConstCSE = true ;
521- }
502+ size_t key;
503+ unsigned hval;
504+ CSEdsc* hashDsc;
505+ const bool enableSharedConstCSE = optSharedConstantCSEEnabled ();
506+ bool isSharedConst = false ;
522507
523508 // We use the liberal Value numbers when building the set of CSE
524509 ValueNum vnLib = tree->GetVN (VNK_Liberal);
@@ -1759,34 +1744,12 @@ void Compiler::optValnumCSE_Availability()
17591744//
17601745CSE_HeuristicCommon::CSE_HeuristicCommon (Compiler* pCompiler) : m_pCompiler(pCompiler)
17611746{
1762- m_addCSEcount = 0 ; /* Count of the number of LclVars for CSEs that we added */
1763- sortTab = nullptr ;
1764- sortSiz = 0 ;
1765- madeChanges = false ;
1766- codeOptKind = m_pCompiler->compCodeOpt ();
1767-
1768- enableConstCSE = true ;
1769-
1770- int configValue = JitConfig.JitConstCSE ();
1771-
1772- // all platforms - disable CSE of constant values when config is 1
1773- if (configValue == CONST_CSE_DISABLE_ALL)
1774- {
1775- enableConstCSE = false ;
1776- }
1777-
1778- #if !defined(TARGET_ARM64)
1779- // non-ARM64 platforms - disable by default
1780- //
1781- enableConstCSE = false ;
1782-
1783- // Check for the two enable cases for all platforms
1784- //
1785- if ((configValue == CONST_CSE_ENABLE_ALL) || (configValue == CONST_CSE_ENABLE_ALL_NO_SHARING))
1786- {
1787- enableConstCSE = true ;
1788- }
1789- #endif
1747+ m_addCSEcount = 0 ; /* Count of the number of LclVars for CSEs that we added */
1748+ sortTab = nullptr ;
1749+ sortSiz = 0 ;
1750+ madeChanges = false ;
1751+ codeOptKind = m_pCompiler->compCodeOpt ();
1752+ enableConstCSE = Compiler::optConstantCSEEnabled ();
17901753
17911754#ifdef DEBUG
17921755 // Track the order of CSEs done (candidate number)
@@ -5460,6 +5423,56 @@ void Compiler::optCleanupCSEs()
54605423 }
54615424}
54625425
5426+ // ---------------------------------------------------------------------------
5427+ // optSharedConstantCSEEnabled: Returns `true` if shared constant CSE is enabled.
5428+ //
5429+ // Notes: see `optConstantCSEEnabled` for detecting if general constant CSE is enabled.
5430+ //
5431+ // static
5432+ bool Compiler::optSharedConstantCSEEnabled ()
5433+ {
5434+ bool enableSharedConstCSE = false ;
5435+ int configValue = JitConfig.JitConstCSE ();
5436+
5437+ if (configValue == CONST_CSE_ENABLE_ALL)
5438+ {
5439+ enableSharedConstCSE = true ;
5440+ }
5441+ #if defined(TARGET_ARMARCH)
5442+ else if (configValue == CONST_CSE_ENABLE_ARM)
5443+ {
5444+ enableSharedConstCSE = true ;
5445+ }
5446+ #endif // TARGET_ARMARCH
5447+
5448+ return enableSharedConstCSE;
5449+ }
5450+
5451+ // ---------------------------------------------------------------------------
5452+ // optConstantCSEEnabled: Returns `true` if constant CSE is enabled.
5453+ //
5454+ // Notes: see `optSharedConstantCSEEnabled` for detecting if shared constant CSE is enabled.
5455+ //
5456+ // static
5457+ bool Compiler::optConstantCSEEnabled ()
5458+ {
5459+ bool enableConstCSE = false ;
5460+ int configValue = JitConfig.JitConstCSE ();
5461+
5462+ if ((configValue == CONST_CSE_ENABLE_ALL) || (configValue == CONST_CSE_ENABLE_ALL_NO_SHARING))
5463+ {
5464+ enableConstCSE = true ;
5465+ }
5466+ #if defined(TARGET_ARMARCH)
5467+ else if ((configValue == CONST_CSE_ENABLE_ARM) || (configValue == CONST_CSE_ENABLE_ARM_NO_SHARING))
5468+ {
5469+ enableConstCSE = true ;
5470+ }
5471+ #endif
5472+
5473+ return enableConstCSE;
5474+ }
5475+
54635476#ifdef DEBUG
54645477
54655478/* ****************************************************************************
0 commit comments