Skip to content

Commit

Permalink
"==0" optimization in Boolean logic #13573 (#49548)
Browse files Browse the repository at this point in the history
* Equals to 0 optimization in Boolean logic

* Limit bool optimization to Integral return type only

* Use the updated flowList:setEdgeWeights method with the 3rd parameter

* Skip bool optimization for cases that require NOT transformation

* Skip bool optimization when the third block GT_RETURN is not CNT_INT int

* format patch

* Added more bool optimization cases

* format patch

* Refactored setting fold type and comparison type to fix jitstress error

* format patch

* Refactored common codes for conditional block and return block boolean optimizations

* format patch

* Unit test changed to remove EH handling and add return value checks

* Unit test: add back test cases for ANDing and NE cases

* Made OptBoolsDsc struct to pass it off to the helper methods.

* format patch

* Changed to substructure OptTestInfo within OptBoolsDisc

* Cleaned up tree variables in OptBoolsDsc struct

* Moved some methods for Boolean Optimization to OptBoolsDsc struct

* Moved all private methods for Boolean Optimization to OptBoolsDsc struct

* Boolean Optimization: Handled code review feedback

* Optimize bools: hoisted jump destination check to optOptimizeBools() and added test cases

* format patch

* Moved initialization to OptBoolsDsc constructor

* format patch

Co-authored-by: Julie Lee <[email protected]>
  • Loading branch information
JulieLeeMSFT and ewhapdx authored Jul 14, 2021
1 parent b412aac commit 8a34e76
Show file tree
Hide file tree
Showing 4 changed files with 1,051 additions and 343 deletions.
6 changes: 1 addition & 5 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class FgStack; // defined in fgbasic.cpp
class Instrumentor; // defined in fgprofile.cpp
class SpanningTreeVisitor; // defined in fgprofile.cpp
class CSE_DataFlow; // defined in OptCSE.cpp
class OptBoolsDsc; // defined in optimizer.cpp
#ifdef DEBUG
struct IndentStack;
#endif
Expand Down Expand Up @@ -6350,11 +6351,6 @@ class Compiler
public:
void optOptimizeBools();

private:
GenTree* optIsBoolCond(GenTree* condBranch, GenTree** compPtr, bool* boolPtr);
#ifdef DEBUG
void optOptimizeBoolsGcStress(BasicBlock* condBlock);
#endif
public:
PhaseStatus optInvertLoops(); // Invert loops so they're entered at top and tested at bottom.
PhaseStatus optOptimizeLayout(); // Optimize the BasicBlock layout of the method
Expand Down
Loading

0 comments on commit 8a34e76

Please sign in to comment.