From a331b56082b9cb3f2c3fd737a5a014adc782156f Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Fri, 19 May 2023 22:38:33 +0200 Subject: [PATCH] Remove fgMorphCastedBitwiseOp (#86491) --- src/coreclr/jit/compiler.h | 1 - src/coreclr/jit/morph.cpp | 78 ---------------------------------------------- 2 files changed, 79 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index fc02278..0ca7bdc 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -6001,7 +6001,6 @@ private: GenTree* fgMorphConst(GenTree* tree); GenTreeOp* fgMorphCommutative(GenTreeOp* tree); - GenTree* fgMorphCastedBitwiseOp(GenTreeOp* tree); GenTree* fgMorphReduceAddOps(GenTree* tree); diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index b1db6f5..71469e7 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -8347,75 +8347,6 @@ GenTreeOp* Compiler::fgMorphCommutative(GenTreeOp* tree) return op1->AsOp(); } -//------------------------------------------------------------------------------ -// fgMorphCastedBitwiseOp : Try to simplify "(T)x op (T)y" to "(T)(x op y)". -// -// Arguments: -// tree - node to fold -// -// Return Value: -// A folded GenTree* instance, or nullptr if it couldn't be folded -GenTree* Compiler::fgMorphCastedBitwiseOp(GenTreeOp* tree) -{ - // This transform does not preserve VNs and deletes a node. - assert(fgGlobalMorph); - assert(varTypeIsIntegralOrI(tree)); - assert(tree->OperIs(GT_OR, GT_AND, GT_XOR)); - - GenTree* op1 = tree->gtGetOp1(); - GenTree* op2 = tree->gtGetOp2(); - genTreeOps oper = tree->OperGet(); - - // see whether both ops are casts, with matching to and from types. - if (op1->OperIs(GT_CAST) && op2->OperIs(GT_CAST)) - { - // bail if either operand is a checked cast - if (op1->gtOverflow() || op2->gtOverflow()) - { - return nullptr; - } - - var_types fromType = op1->AsCast()->CastOp()->TypeGet(); - var_types toType = op1->AsCast()->CastToType(); - bool isUnsigned = op1->IsUnsigned(); - - if (varTypeIsFloating(fromType) || (op2->CastFromType() != fromType) || (op2->CastToType() != toType) || - (op2->IsUnsigned() != isUnsigned)) - { - return nullptr; - } - - /* - // Reuse gentree nodes: - // - // tree op1 - // / \ | - // op1 op2 ==> tree - // | | / \. - // x y x y - // - // (op2 becomes garbage) - */ - - tree->gtOp1 = op1->AsCast()->CastOp(); - tree->gtOp2 = op2->AsCast()->CastOp(); - tree->gtType = genActualType(fromType); - - op1->gtType = genActualType(toType); - op1->AsCast()->gtOp1 = tree; - op1->AsCast()->CastToType() = toType; - op1->SetAllEffectsFlags(tree); - // no need to update isUnsigned - - DEBUG_DESTROY_NODE(op2); - INDEBUG(op1->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); - - return op1; - } - - return nullptr; -} - //------------------------------------------------------------------------ // fgMorphSmpOp: morph a GTK_SMPOP tree // @@ -10862,15 +10793,6 @@ GenTree* Compiler::fgOptimizeCommutativeArithmetic(GenTreeOp* tree) } } - if (fgGlobalMorph && tree->OperIs(GT_AND, GT_OR, GT_XOR)) - { - GenTree* castTree = fgMorphCastedBitwiseOp(tree->AsOp()); - if (castTree != nullptr) - { - return castTree; - } - } - if (varTypeIsIntegralOrI(tree)) { genTreeOps oldTreeOper = tree->OperGet(); -- 2.7.4