C++: Tidy primitive_basic_block_member calculation

This change gave a slight speed-up by eliminating an unnecessary
intermediate predicate.
This commit is contained in:
Jonas Jensen
2018-09-01 07:46:00 +02:00
parent e7234f5cf3
commit 98612b9f9a

View File

@@ -43,12 +43,13 @@ private cached module Cached {
(not successors_extended(_, node) and successors_extended(node, _))
}
pragma[noinline]
/** Holds if `n2` follows `n1` in a `PrimitiveBasicBlock`. */
private predicate member_step(Node n1, Node n2) {
successors_extended(n1, n2) and
not n2 instanceof PrimitiveBasicBlock
}
/** Returns the index of `node` in its `PrimitiveBasicBlock`. */
private int getMemberIndex(Node node) {
primitive_basic_block_entry_node(node) and
result = 0
@@ -59,15 +60,11 @@ private cached module Cached {
)
}
private predicate isMember(Node node, PrimitiveBasicBlock bb) {
member_step*(bb, node)
}
/** Holds if `node` is the `pos`th control-flow node in primitive basic block `bb`. */
cached
predicate primitive_basic_block_member(Node node, PrimitiveBasicBlock bb, int pos) {
pos = getMemberIndex(node) and
isMember(node, bb)
member_step*(bb, node)
}
/** Gets the number of control-flow nodes in the primitive basic block `bb`. */