Region::Ideal trims a current RegionNode if there are null or top inputs.
eg. there are 3 top inputs. Region 100 is still reachable, but its predecessors 2 4, 5 are not.
100 Region === [100, 200, top, 300, top, top]
110 Phi === [100, 210, a, 310, b, c]
Region::Ideal will trim this region node. Not only itself, it also needs to change its PHINodes.
100 Region === [100, 200, 300]
110 Phi === [100, 210, 310]
Whatever a, b, c are, they are all gone.
My patch optimizes Region::Ideal implementation in the following points. I merely attempt to makes compiler faster and more easy to read. We expect to have the effect.
1. Don't restart from beginning. Trimming doesn't change the DU-chain.
2. Replace DFIterator with DFIterator_Fast. The later is a raw pointer in release build.
3. Don't call add_users_to_worklist(this) repeatly.
4. Reduce its strength from add_users_to_worklist to add_users_to_worklist0 because RegionNode has no special logic.
This patch also includes a cosmetic change: rename n to 'use' inside of the loop. Otherwise, we would overshadow Node* n = in(i). Nothing wrong but harder to read.
eg. there are 3 top inputs. Region 100 is still reachable, but its predecessors 2 4, 5 are not.
100 Region === [100, 200, top, 300, top, top]
110 Phi === [100, 210, a, 310, b, c]
Region::Ideal will trim this region node. Not only itself, it also needs to change its PHINodes.
100 Region === [100, 200, 300]
110 Phi === [100, 210, 310]
Whatever a, b, c are, they are all gone.
My patch optimizes Region::Ideal implementation in the following points. I merely attempt to makes compiler faster and more easy to read. We expect to have the effect.
1. Don't restart from beginning. Trimming doesn't change the DU-chain.
2. Replace DFIterator with DFIterator_Fast. The later is a raw pointer in release build.
3. Don't call add_users_to_worklist(this) repeatly.
4. Reduce its strength from add_users_to_worklist to add_users_to_worklist0 because RegionNode has no special logic.
This patch also includes a cosmetic change: rename n to 'use' inside of the loop. Otherwise, we would overshadow Node* n = in(i). Nothing wrong but harder to read.