Helper function for FactorAddSubMuls. If |factor0_0| is the same as |factor1_0|, generate: |factor0_0| * (|factor0_1| + |factor1_1|) |factor0_0| * (|factor0_1| - |factor1_1|)
| 1561 | // |factor0_0| * (|factor0_1| + |factor1_1|) |
| 1562 | // |factor0_0| * (|factor0_1| - |factor1_1|) |
| 1563 | bool FactorAddSubMulsOpnds(uint32_t factor0_0, uint32_t factor0_1, |
| 1564 | uint32_t factor1_0, uint32_t factor1_1, |
| 1565 | Instruction* inst) { |
| 1566 | IRContext* context = inst->context(); |
| 1567 | if (factor0_0 != factor1_0) return false; |
| 1568 | InstructionBuilder ir_builder( |
| 1569 | context, inst, |
| 1570 | IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); |
| 1571 | Instruction* new_add_inst = ir_builder.AddBinaryOp( |
| 1572 | inst->type_id(), inst->opcode(), factor0_1, factor1_1); |
| 1573 | if (!new_add_inst) { |
| 1574 | return false; |
| 1575 | } |
| 1576 | |
| 1577 | bool is_float = |
| 1578 | inst->opcode() == spv::Op::OpFAdd || inst->opcode() == spv::Op::OpFSub; |
| 1579 | inst->SetOpcode(is_float ? spv::Op::OpFMul : spv::Op::OpIMul); |
| 1580 | inst->SetInOperands({{SPV_OPERAND_TYPE_ID, {factor0_0}}, |
| 1581 | {SPV_OPERAND_TYPE_ID, {new_add_inst->result_id()}}}); |
| 1582 | context->UpdateDefUse(inst); |
| 1583 | return true; |
| 1584 | } |
| 1585 | |
| 1586 | // Perform the following factoring identity, handling all operand order |
| 1587 | // combinations: |
no test coverage detected