@@ -1379,6 +1379,56 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1379
1379
not def .definesAt ( v , getImmediateBasicBlockDominator * ( bb ) , _)
1380
1380
)
1381
1381
}
1382
+
1383
+ /** Holds if the end of a basic block can be reached by multiple definitions. */
1384
+ query predicate nonUniqueDefReachesEndOfBlock ( Definition def , SourceVariable v , BasicBlock bb ) {
1385
+ ssaDefReachesEndOfBlock ( bb , def , v ) and
1386
+ not exists ( unique( Definition def0 | ssaDefReachesEndOfBlock ( bb , def0 , v ) ) )
1387
+ }
1388
+
1389
+ /** Holds if a phi node has less than two inputs. */
1390
+ query predicate uselessPhiNode ( PhiNode phi , int inputs ) {
1391
+ inputs = count ( Definition inp | phiHasInputFromBlock ( phi , inp , _) ) and
1392
+ inputs < 2
1393
+ }
1394
+
1395
+ /** Holds if a certain read does not have a prior reference. */
1396
+ query predicate readWithoutPriorRef ( SourceVariable v , BasicBlock bb , int i ) {
1397
+ variableRead ( bb , i , v , true ) and
1398
+ not AdjacentSsaRefs:: adjacentRefRead ( _, _, bb , i , v )
1399
+ }
1400
+
1401
+ /**
1402
+ * Holds if a certain read has multiple prior references. The introduction
1403
+ * of phi reads should make the prior reference unique.
1404
+ */
1405
+ query predicate readWithMultiplePriorRefs (
1406
+ SourceVariable v , BasicBlock bb1 , int i1 , BasicBlock bb2 , int i2
1407
+ ) {
1408
+ AdjacentSsaRefs:: adjacentRefRead ( bb1 , i1 , bb2 , i2 , v ) and
1409
+ 2 <=
1410
+ strictcount ( BasicBlock bb0 , int i0 | AdjacentSsaRefs:: adjacentRefRead ( bb0 , i0 , bb1 , i1 , v ) )
1411
+ }
1412
+
1413
+ /** Holds if `phi` has less than 2 immediately prior references. */
1414
+ query predicate phiWithoutTwoPriorRefs ( PhiNode phi , int inputRefs ) {
1415
+ exists ( BasicBlock bbPhi , SourceVariable v |
1416
+ phi .definesAt ( v , bbPhi , _) and
1417
+ inputRefs =
1418
+ count ( BasicBlock bb , int i | AdjacentSsaRefs:: adjacentRefPhi ( bb , i , _, bbPhi , v ) ) and
1419
+ inputRefs < 2
1420
+ )
1421
+ }
1422
+
1423
+ /**
1424
+ * Holds if the phi read for `v` at `bb` has less than 2 immediately prior
1425
+ * references.
1426
+ */
1427
+ query predicate phiReadWithoutTwoPriorRefs ( BasicBlock bbPhi , SourceVariable v , int inputRefs ) {
1428
+ synthPhiRead ( bbPhi , v ) and
1429
+ inputRefs = count ( BasicBlock bb , int i | AdjacentSsaRefs:: adjacentRefPhi ( bb , i , _, bbPhi , v ) ) and
1430
+ inputRefs < 2
1431
+ }
1382
1432
}
1383
1433
1384
1434
/** Provides the input to `DataFlowIntegration`. */
0 commit comments