From 16390d8d46532b6dcc7d047307ede89d24284a3b Mon Sep 17 00:00:00 2001 From: EgorBo Date: Fri, 19 Jul 2024 16:34:29 +0200 Subject: [PATCH] don't narrow cast(ind(x)) --- src/coreclr/jit/optimizer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index 8fb5ca0493566..614340acab3b7 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -3518,6 +3518,13 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu case GT_IND: + if (opts.OptimizationEnabled()) + { + // Don't narrow casts of indirections when optimizations are enabled + // to enable more CSEs. + return false; + } + NARROW_IND: if ((dstSize > genTypeSize(tree->gtType)) &&