From 637bfeffb0fd0378ff6d04d7bb845938b77bdade Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 22 Aug 2017 17:04:02 -0700 Subject: [PATCH] JIT: don't self assign to temps (#13484) Modify gtNewTempAssign to more generally map self-assignment of temps into nops. We already were doing something similar over in `impAssignStruct`, and now we catch non-struct cases too. --- src/jit/gentree.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 66155db..186c37b 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -13855,13 +13855,33 @@ DONE: #pragma warning(pop) #endif -/***************************************************************************** - * - * Create an assignment of the given value to a temp. - */ +//------------------------------------------------------------------------ +// gtNewTempAssign: Create an assignment of the given value to a temp. +// +// Arguments: +// tmp - local number for a compiler temp +// val - value to assign to the temp +// +// Return Value: +// Normally a new assignment node. +// However may return a nop node if val is simply a reference to the temp. +// +// Notes: +// Self-assignments may be represented via NOPs. +// +// May update the type of the temp, if it was previously unknown. +// +// May set compFloatingPointUsed. +// GenTreePtr Compiler::gtNewTempAssign(unsigned tmp, GenTreePtr val) { + // Self-assignment is a nop. + if (val->OperGet() == GT_LCL_VAR && val->gtLclVarCommon.gtLclNum == tmp) + { + return gtNewNothingNode(); + } + LclVarDsc* varDsc = lvaTable + tmp; if (varDsc->TypeGet() == TYP_I_IMPL && val->TypeGet() == TYP_BYREF) -- 2.7.4