5 #include "src/compiler/node-matchers.h" 11 bool NodeMatcher::IsComparison()
const {
12 return IrOpcode::IsComparisonOpcode(opcode());
16 BranchMatcher::BranchMatcher(Node* branch)
17 : NodeMatcher(branch), if_true_(nullptr), if_false_(nullptr) {
18 if (branch->opcode() != IrOpcode::kBranch)
return;
19 for (Node* use : branch->uses()) {
20 if (use->opcode() == IrOpcode::kIfTrue) {
21 DCHECK_NULL(if_true_);
23 }
else if (use->opcode() == IrOpcode::kIfFalse) {
24 DCHECK_NULL(if_false_);
31 DiamondMatcher::DiamondMatcher(Node* merge)
36 if (merge->InputCount() != 2)
return;
37 if (merge->opcode() != IrOpcode::kMerge)
return;
38 Node* input0 = merge->InputAt(0);
39 if (input0->InputCount() != 1)
return;
40 Node* input1 = merge->InputAt(1);
41 if (input1->InputCount() != 1)
return;
42 Node* branch = input0->InputAt(0);
43 if (branch != input1->InputAt(0))
return;
44 if (branch->opcode() != IrOpcode::kBranch)
return;
45 if (input0->opcode() == IrOpcode::kIfTrue &&
46 input1->opcode() == IrOpcode::kIfFalse) {
50 }
else if (input0->opcode() == IrOpcode::kIfFalse &&
51 input1->opcode() == IrOpcode::kIfTrue) {