Skip to content

Commit 132cc2f

Browse files
Refactor optimizing morph for commutative operations (#63251)
* Create "fgOptimizeCommutativeArithmetic" And just move code from "fgMorphSmpOp" to it. Just one diff: better comma throw propagation in an ILGEN method. * Refactor the function Split it into specialized variants for each operator, delete redundant code, fix up one case of wrong typing for a constant in the MUL -> SHIFT optimization. One CSE diff due to different VNs because of the typing change for the constant (int -> long). Many text diffs: "mov x3, 5" => "mov w3, 5".
1 parent 11f9949 commit 132cc2f

File tree

2 files changed

+386
-341
lines changed

2 files changed

+386
-341
lines changed

src/coreclr/jit/compiler.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -6409,6 +6409,10 @@ class Compiler
64096409
GenTree* fgOptimizeCast(GenTreeCast* cast);
64106410
GenTree* fgOptimizeEqualityComparisonWithConst(GenTreeOp* cmp);
64116411
GenTree* fgOptimizeRelationalComparisonWithConst(GenTreeOp* cmp);
6412+
GenTree* fgOptimizeCommutativeArithmetic(GenTreeOp* tree);
6413+
GenTree* fgOptimizeAddition(GenTreeOp* add);
6414+
GenTree* fgOptimizeMultiply(GenTreeOp* mul);
6415+
GenTree* fgOptimizeBitwiseAnd(GenTreeOp* andOp);
64126416
GenTree* fgPropagateCommaThrow(GenTree* parent, GenTreeOp* commaThrow, GenTreeFlags precedingSideEffects);
64136417
GenTree* fgMorphRetInd(GenTreeUnOp* tree);
64146418
GenTree* fgMorphModToSubMulDiv(GenTreeOp* tree);
@@ -6419,7 +6423,7 @@ class Compiler
64196423
bool fgMorphCanUseLclFldForCopy(unsigned lclNum1, unsigned lclNum2);
64206424

64216425
GenTreeLclVar* fgMorphTryFoldObjAsLclVar(GenTreeObj* obj);
6422-
GenTree* fgMorphCommutative(GenTreeOp* tree);
6426+
GenTreeOp* fgMorphCommutative(GenTreeOp* tree);
64236427
GenTree* fgMorphCastedBitwiseOp(GenTreeOp* tree);
64246428

64256429
GenTree* fgMorphReduceAddOps(GenTree* tree);

0 commit comments

Comments
 (0)