@@ -2593,6 +2593,15 @@ module ControlFlow {
25932593 this = TPhiPreSsaDef ( _, result )
25942594 }
25952595
2596+ LocalScopeVariableRead getARead ( ) {
2597+ firstReadSameVar ( this , result )
2598+ or
2599+ exists ( LocalScopeVariableRead read |
2600+ firstReadSameVar ( this , read ) |
2601+ adjacentReadPairSameVar + ( read , result )
2602+ )
2603+ }
2604+
25962605 Location getLocation ( ) {
25972606 exists ( AssignableDefinition def |
25982607 this = TExplicitPreSsaDef ( _, _, def , _) |
@@ -2720,21 +2729,29 @@ module ControlFlow {
27202729 ssaRefRank ( bb2 , i2 , v , _) = 1
27212730 }
27222731
2723- predicate firstReadSameVar ( Definition def , LocalScopeVariableRead read ) {
2724- exists ( SimpleLocalScopeVariable v , PreBasicBlock b1 , int i1 , PreBasicBlock b2 , int i2 |
2725- adjacentVarRefs ( v , b1 , i1 , b2 , i2 ) and
2726- defAt ( b1 , i1 , def , v ) and
2727- readAt ( b2 , i2 , read , v )
2728- )
2729- }
2732+ private cached module PreSsaCached {
2733+ cached
2734+ predicate firstReadSameVar ( Definition def , LocalScopeVariableRead read ) {
2735+ exists ( SimpleLocalScopeVariable v , PreBasicBlock b1 , int i1 , PreBasicBlock b2 , int i2 |
2736+ adjacentVarRefs ( v , b1 , i1 , b2 , i2 ) and
2737+ defAt ( b1 , i1 , def , v ) and
2738+ readAt ( b2 , i2 , read , v )
2739+ )
2740+ }
27302741
2731- predicate adjacentReadPairSameVar ( LocalScopeVariableRead read1 , LocalScopeVariableRead read2 ) {
2732- exists ( SimpleLocalScopeVariable v , PreBasicBlock bb1 , int i1 , PreBasicBlock bb2 , int i2 |
2733- adjacentVarRefs ( v , bb1 , i1 , bb2 , i2 ) and
2734- readAt ( bb1 , i1 , read1 , v ) and
2735- readAt ( bb2 , i2 , read2 , v )
2736- )
2742+ cached
2743+ predicate adjacentReadPairSameVar ( LocalScopeVariableRead read1 , LocalScopeVariableRead read2 ) {
2744+ exists ( SimpleLocalScopeVariable v , PreBasicBlock bb1 , int i1 , PreBasicBlock bb2 , int i2 |
2745+ adjacentVarRefs ( v , bb1 , i1 , bb2 , i2 ) and
2746+ readAt ( bb1 , i1 , read1 , v ) and
2747+ readAt ( bb2 , i2 , read2 , v )
2748+ )
2749+ }
2750+
2751+ cached
2752+ predicate forceCachingInSameStage ( ) { any ( ) }
27372753 }
2754+ import PreSsaCached
27382755 }
27392756
27402757 /**
@@ -3327,11 +3344,7 @@ module ControlFlow {
33273344 * Holds if condition `cb` is a read of the SSA variable in this split.
33283345 */
33293346 private predicate defCondition ( ConditionBlock cb ) {
3330- exists ( LocalScopeVariableRead read1 , LocalScopeVariableRead read2 |
3331- firstReadSameVar ( def , read1 ) |
3332- adjacentReadPairSameVar * ( read1 , read2 ) and
3333- read2 = cb .getLastElement ( )
3334- )
3347+ cb .getLastElement ( ) = def .getARead ( )
33353348 }
33363349
33373350 /**
@@ -3827,6 +3840,7 @@ module ControlFlow {
38273840 cached
38283841 newtype TPreSsaDef =
38293842 TExplicitPreSsaDef ( PreBasicBlocks:: PreBasicBlock bb , int i , AssignableDefinition def , LocalScopeVariable v ) {
3843+ PreSsa:: forceCachingInSameStage ( ) and
38303844 PreSsa:: assignableDefAt ( bb , i , def , v )
38313845 }
38323846 or
0 commit comments