File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -11019,16 +11019,15 @@ GenTree* Compiler::fgOptimizeAddition(GenTreeOp* add)
1101911019 GenTreeOp* addOne = op1->AsOp();
1102011020 GenTreeOp* addTwo = op2->AsOp();
1102111021 GenTreeIntCon* constOne = addOne->gtGetOp2()->AsIntCon();
11022- GenTreeIntCon* constTwo = addTwo->gtGetOp2()->AsIntCon();
1102311022
11023+ // addOne is now "x + y"
1102411024 addOne->gtOp2 = addTwo->gtGetOp1();
1102511025 addOne->SetAllEffectsFlags(addOne->gtGetOp1(), addOne->gtGetOp2());
11026- DEBUG_DESTROY_NODE(addTwo);
1102711026
11028- constOne->SetValueTruncating(constOne->IconValue() + constTwo->IconValue());
11029- op2 = constOne;
11030- add->gtOp2 = constOne ;
11031- DEBUG_DESTROY_NODE(constTwo );
11027+ // addTwo is now "icon1 + icon2" so we can fold it using gtFoldExprConst
11028+ addTwo->gtOp1 = constOne;
11029+ add->gtOp2 = gtFoldExprConst(add->gtOp2) ;
11030+ op2 = add->gtGetOp2( );
1103211031 }
1103311032
1103411033 // Fold (x + 0) - given it won't change the tree type.
You can’t perform that action at this time.
0 commit comments