From cee764f3f3781c7ca16c9d81603a66cc0cfceded Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sun, 2 Jun 2024 16:35:16 -0700 Subject: [PATCH] Don't needlessly track the method handle for hwintrinsics when optimizations are disabled --- src/coreclr/jit/hwintrinsic.cpp | 12 ++++++++++++ src/coreclr/jit/hwintrinsicarm64.cpp | 14 ++++++++++++++ src/coreclr/jit/hwintrinsicxarch.cpp | 14 ++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index fe40c7cc145309..48dd3cffa10465 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1312,6 +1312,12 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, { return impNonConstFallback(intrinsic, retType, simdBaseJitType); } + else if (!opts.OptimizationEnabled()) + { + // Only enable late stage rewriting if optimizations are enabled + // as we won't otherwise encounter a constant at the later point + return nullptr; + } else { setMethodHandle = true; @@ -1343,6 +1349,12 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, { return impNonConstFallback(intrinsic, retType, simdBaseJitType); } + else if (!opts.OptimizationEnabled()) + { + // Only enable late stage rewriting if optimizations are enabled + // as we won't otherwise encounter a constant at the later point + return nullptr; + } else { setMethodHandle = true; diff --git a/src/coreclr/jit/hwintrinsicarm64.cpp b/src/coreclr/jit/hwintrinsicarm64.cpp index d1ea6e33be12b1..9622d8a73c6d0b 100644 --- a/src/coreclr/jit/hwintrinsicarm64.cpp +++ b/src/coreclr/jit/hwintrinsicarm64.cpp @@ -1877,6 +1877,13 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, { assert(sig->numArgs == 2); + if (!opts.OptimizationEnabled()) + { + // Only enable late stage rewriting if optimizations are enabled + // as we won't otherwise encounter a constant at the later point + return nullptr; + } + op2 = impSIMDPopStack(); op1 = impSIMDPopStack(); @@ -2215,6 +2222,13 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, if (!indexOp->OperIsConst()) { + if (!opts.OptimizationEnabled()) + { + // Only enable late stage rewriting if optimizations are enabled + // as we won't otherwise encounter a constant at the later point + return nullptr; + } + op3 = impPopStack().val; op2 = impPopStack().val; op1 = impSIMDPopStack(); diff --git a/src/coreclr/jit/hwintrinsicxarch.cpp b/src/coreclr/jit/hwintrinsicxarch.cpp index 8abd4c64e66c10..42447b7625ab1e 100644 --- a/src/coreclr/jit/hwintrinsicxarch.cpp +++ b/src/coreclr/jit/hwintrinsicxarch.cpp @@ -2903,6 +2903,13 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, { assert(sig->numArgs == 2); + if (!opts.OptimizationEnabled()) + { + // Only enable late stage rewriting if optimizations are enabled + // as we won't otherwise encounter a constant at the later point + return nullptr; + } + op2 = impSIMDPopStack(); op1 = impSIMDPopStack(); @@ -3215,6 +3222,13 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, if (!indexOp->OperIsConst()) { + if (!opts.OptimizationEnabled()) + { + // Only enable late stage rewriting if optimizations are enabled + // as we won't otherwise encounter a constant at the later point + return nullptr; + } + op3 = impPopStack().val; op2 = impPopStack().val; op1 = impSIMDPopStack();