Handles both addition and subtraction. If the |sub| flag is set then the addition will be op1+(-op2) otherwise op1+op2.
| 225 | // Handles both addition and subtraction. If the |sub| flag is set then the |
| 226 | // addition will be op1+(-op2) otherwise op1+op2. |
| 227 | SENode* ScalarEvolutionAnalysis::AnalyzeAddOp(const Instruction* inst) { |
| 228 | assert((inst->opcode() == spv::Op::OpIAdd || |
| 229 | inst->opcode() == spv::Op::OpISub) && |
| 230 | "Add node must be created from a OpIAdd or OpISub instruction"); |
| 231 | |
| 232 | analysis::DefUseManager* def_use = context_->get_def_use_mgr(); |
| 233 | |
| 234 | SENode* op1 = |
| 235 | AnalyzeInstruction(def_use->GetDef(inst->GetSingleWordInOperand(0))); |
| 236 | |
| 237 | SENode* op2 = |
| 238 | AnalyzeInstruction(def_use->GetDef(inst->GetSingleWordInOperand(1))); |
| 239 | |
| 240 | // To handle subtraction we wrap the second operand in a unary negation node. |
| 241 | if (inst->opcode() == spv::Op::OpISub) { |
| 242 | op2 = CreateNegation(op2); |
| 243 | } |
| 244 | |
| 245 | return CreateAddNode(op1, op2); |
| 246 | } |
| 247 | |
| 248 | SENode* ScalarEvolutionAnalysis::AnalyzePhiInstruction(const Instruction* phi) { |
| 249 | // The phi should only have two incoming value pairs. |
nothing calls this directly
no test coverage detected