MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / AnalyzeAddOp

Method AnalyzeAddOp

source/opt/scalar_analysis.cpp:227–246  ·  view source on GitHub ↗

Handles both addition and subtraction. If the |sub| flag is set then the addition will be op1+(-op2) otherwise op1+op2.

Source from the content-addressed store, hash-verified

225// Handles both addition and subtraction. If the |sub| flag is set then the
226// addition will be op1+(-op2) otherwise op1+op2.
227SENode* 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
248SENode* ScalarEvolutionAnalysis::AnalyzePhiInstruction(const Instruction* phi) {
249 // The phi should only have two incoming value pairs.

Callers

nothing calls this directly

Calls 4

opcodeMethod · 0.45
get_def_use_mgrMethod · 0.45
GetDefMethod · 0.45

Tested by

no test coverage detected