Lines Matching refs:SENode
81 SENode* node_to_simplify) in SENodeSimplifyImpl()
87 SENode* Simplify();
95 void GatherAccumulatorsFromChildNodes(SENode* new_node, SENode* child,
103 bool AccumulatorsFromMultiply(SENode* multiply, bool negation);
111 SENode* SimplifyRecurrentAddExpression(SERecurrentNode* node);
116 SENode* SimplifyPolynomial();
129 SENode* FoldRecurrentAddExpressions(SENode*);
135 SENode* EliminateZeroCoefficientRecurrents(SENode* node);
141 SENode* node_;
148 std::map<SENode*, int64_t> accumulators_;
152 bool SENodeSimplifyImpl::AccumulatorsFromMultiply(SENode* multiply, in AccumulatorsFromMultiply()
155 multiply->GetType() != SENode::Multiply) in AccumulatorsFromMultiply()
158 SENode* operand_1 = multiply->GetChild(0); in AccumulatorsFromMultiply()
159 SENode* operand_2 = multiply->GetChild(1); in AccumulatorsFromMultiply()
161 SENode* value_unknown = nullptr; in AccumulatorsFromMultiply()
162 SENode* constant = nullptr; in AccumulatorsFromMultiply()
165 if (operand_1->GetType() == SENode::ValueUnknown || in AccumulatorsFromMultiply()
166 operand_1->GetType() == SENode::RecurrentAddExpr) in AccumulatorsFromMultiply()
168 else if (operand_2->GetType() == SENode::ValueUnknown || in AccumulatorsFromMultiply()
169 operand_2->GetType() == SENode::RecurrentAddExpr) in AccumulatorsFromMultiply()
173 if (operand_1->GetType() == SENode::Constant) in AccumulatorsFromMultiply()
175 else if (operand_2->GetType() == SENode::Constant) in AccumulatorsFromMultiply()
198 SENode* SENodeSimplifyImpl::Simplify() { in Simplify()
201 if (node_->GetType() != SENode::Add && node_->GetType() != SENode::Multiply && in Simplify()
202 node_->GetType() != SENode::Negative) in Simplify()
205 SENode* simplified_polynomial = SimplifyPolynomial(); in Simplify()
219 for (SENode* child : simplified_polynomial->GetChildren()) { in Simplify()
220 if (child->GetType() == SENode::RecurrentAddExpr) { in Simplify()
229 if (child_iterator->GetType() == SENode::RecurrentAddExpr && in Simplify()
243 void SENodeSimplifyImpl::GatherAccumulatorsFromChildNodes(SENode* new_node, in GatherAccumulatorsFromChildNodes()
244 SENode* child, in GatherAccumulatorsFromChildNodes()
248 if (child->GetType() == SENode::Constant) { in GatherAccumulatorsFromChildNodes()
253 } else if (child->GetType() == SENode::ValueUnknown || in GatherAccumulatorsFromChildNodes()
254 child->GetType() == SENode::RecurrentAddExpr) { in GatherAccumulatorsFromChildNodes()
267 } else if (child->GetType() == SENode::Multiply) { in GatherAccumulatorsFromChildNodes()
272 } else if (child->GetType() == SENode::Add) { in GatherAccumulatorsFromChildNodes()
273 for (SENode* next_child : *child) { in GatherAccumulatorsFromChildNodes()
277 } else if (child->GetType() == SENode::Negative) { in GatherAccumulatorsFromChildNodes()
278 SENode* negated_node = child->GetChild(0); in GatherAccumulatorsFromChildNodes()
292 SENode* new_coefficient = analysis_.CreateMultiplyNode( in UpdateCoefficient()
297 SENode* simplified = analysis_.SimplifyExpression(new_coefficient); in UpdateCoefficient()
298 if (simplified->GetType() != SENode::CanNotCompute) in UpdateCoefficient()
315 SENode* SENodeSimplifyImpl::SimplifyPolynomial() { in SimplifyPolynomial()
316 std::unique_ptr<SENode> new_add{new SEAddNode(node_->GetParentAnalysis())}; in SimplifyPolynomial()
327 SENode* term = pair.first; in SimplifyPolynomial()
335 } else if (count == -1 && term->GetType() != SENode::RecurrentAddExpr) { in SimplifyPolynomial()
345 if (term->GetType() == SENode::ValueUnknown) { in SimplifyPolynomial()
346 SENode* count_as_constant = analysis_.CreateConstant(count); in SimplifyPolynomial()
350 assert(term->GetType() == SENode::RecurrentAddExpr && in SimplifyPolynomial()
373 SENode* SENodeSimplifyImpl::FoldRecurrentAddExpressions(SENode* root) { in FoldRecurrentAddExpressions()
383 for (SENode* child : *root) { in FoldRecurrentAddExpressions()
386 if (child->GetType() == SENode::Negative) { in FoldRecurrentAddExpressions()
391 if (child->GetType() == SENode::RecurrentAddExpr) { in FoldRecurrentAddExpressions()
413 std::unique_ptr<SENode> new_coefficient{new SEAddNode(&analysis_)}; in FoldRecurrentAddExpressions()
414 std::unique_ptr<SENode> new_offset{new SEAddNode(&analysis_)}; in FoldRecurrentAddExpressions()
433 SENode* new_coefficient_simplified = in FoldRecurrentAddExpressions()
436 SENode* new_offset_simplified = in FoldRecurrentAddExpressions()
439 if (new_coefficient_simplified->GetType() == SENode::Constant && in FoldRecurrentAddExpressions()
459 SENode* SENodeSimplifyImpl::EliminateZeroCoefficientRecurrents(SENode* node) { in EliminateZeroCoefficientRecurrents()
460 if (node->GetType() != SENode::Add) return node; in EliminateZeroCoefficientRecurrents()
464 std::vector<SENode*> new_children{}; in EliminateZeroCoefficientRecurrents()
465 for (SENode* child : *node) { in EliminateZeroCoefficientRecurrents()
466 if (child->GetType() == SENode::RecurrentAddExpr) { in EliminateZeroCoefficientRecurrents()
467 SENode* coefficient = child->AsSERecurrentNode()->GetCoefficient(); in EliminateZeroCoefficientRecurrents()
471 if (coefficient->GetType() == SENode::Constant && in EliminateZeroCoefficientRecurrents()
485 std::unique_ptr<SENode> new_add{new SEAddNode(node_->GetParentAnalysis())}; in EliminateZeroCoefficientRecurrents()
487 for (SENode* child : new_children) { in EliminateZeroCoefficientRecurrents()
494 SENode* SENodeSimplifyImpl::SimplifyRecurrentAddExpression( in SimplifyRecurrentAddExpression()
496 const std::vector<SENode*>& children = node_->GetChildren(); in SimplifyRecurrentAddExpression()
502 std::unique_ptr<SENode> new_offset{ in SimplifyRecurrentAddExpression()
506 for (SENode* child : children) { in SimplifyRecurrentAddExpression()
507 if (child->GetType() != SENode::RecurrentAddExpr) { in SimplifyRecurrentAddExpression()
513 SENode* simplified_child = analysis_.SimplifyExpression(new_offset.get()); in SimplifyRecurrentAddExpression()
517 if (simplified_child->GetType() != SENode::CanNotCompute) { in SimplifyRecurrentAddExpression()
532 SENode* ScalarEvolutionAnalysis::SimplifyExpression(SENode* node) { in SimplifyExpression()