[CodeGen] Convert IslNodeBuilder::getNumberOfIterations to isl++. NFC.
llvm-svn: 338451
This commit is contained in:
parent
f16378b080
commit
e873673b0c
|
@ -259,7 +259,7 @@ protected:
|
||||||
///
|
///
|
||||||
/// NumIter is a non-negative integer value. Condition can have
|
/// NumIter is a non-negative integer value. Condition can have
|
||||||
/// isl_ast_op_lt type.
|
/// isl_ast_op_lt type.
|
||||||
int getNumberOfIterations(__isl_keep isl_ast_node *For);
|
int getNumberOfIterations(isl::ast_node For);
|
||||||
|
|
||||||
/// Compute the values and loops referenced in this subtree.
|
/// Compute the values and loops referenced in this subtree.
|
||||||
///
|
///
|
||||||
|
|
|
@ -156,51 +156,39 @@ static bool checkIslAstExprInt(__isl_take isl_ast_expr *Expr,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IslNodeBuilder::getNumberOfIterations(__isl_keep isl_ast_node *For) {
|
int IslNodeBuilder::getNumberOfIterations(isl::ast_node For) {
|
||||||
assert(isl_ast_node_get_type(For) == isl_ast_node_for);
|
assert(isl_ast_node_get_type(For.get()) == isl_ast_node_for);
|
||||||
auto Body = isl_ast_node_for_get_body(For);
|
isl::ast_node Body = For.for_get_body();
|
||||||
|
|
||||||
// First, check if we can actually handle this code.
|
// First, check if we can actually handle this code.
|
||||||
switch (isl_ast_node_get_type(Body)) {
|
switch (isl_ast_node_get_type(Body.get())) {
|
||||||
case isl_ast_node_user:
|
case isl_ast_node_user:
|
||||||
break;
|
break;
|
||||||
case isl_ast_node_block: {
|
case isl_ast_node_block: {
|
||||||
isl_ast_node_list *List = isl_ast_node_block_get_children(Body);
|
isl::ast_node_list List = Body.block_get_children();
|
||||||
for (int i = 0; i < isl_ast_node_list_n_ast_node(List); ++i) {
|
for (isl::ast_node Node : List) {
|
||||||
isl_ast_node *Node = isl_ast_node_list_get_ast_node(List, i);
|
isl_ast_node_type NodeType = isl_ast_node_get_type(Node.get());
|
||||||
int Type = isl_ast_node_get_type(Node);
|
if (NodeType != isl_ast_node_user)
|
||||||
isl_ast_node_free(Node);
|
|
||||||
if (Type != isl_ast_node_user) {
|
|
||||||
isl_ast_node_list_free(List);
|
|
||||||
isl_ast_node_free(Body);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
isl_ast_node_list_free(List);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
isl_ast_node_free(Body);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
isl_ast_node_free(Body);
|
|
||||||
|
|
||||||
auto Init = isl_ast_node_for_get_init(For);
|
isl::ast_expr Init = For.for_get_init();
|
||||||
if (!checkIslAstExprInt(Init, isl_val_is_zero))
|
if (!checkIslAstExprInt(Init.release(), isl_val_is_zero))
|
||||||
return -1;
|
return -1;
|
||||||
auto Inc = isl_ast_node_for_get_inc(For);
|
isl::ast_expr Inc = For.for_get_inc();
|
||||||
if (!checkIslAstExprInt(Inc, isl_val_is_one))
|
if (!checkIslAstExprInt(Inc.release(), isl_val_is_one))
|
||||||
return -1;
|
return -1;
|
||||||
CmpInst::Predicate Predicate;
|
CmpInst::Predicate Predicate;
|
||||||
auto UB = getUpperBound(isl::manage_copy(For), Predicate).release();
|
isl::ast_expr UB = getUpperBound(For, Predicate);
|
||||||
if (isl_ast_expr_get_type(UB) != isl_ast_expr_int) {
|
if (isl_ast_expr_get_type(UB.get()) != isl_ast_expr_int)
|
||||||
isl_ast_expr_free(UB);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
isl::val UpVal = UB.get_val();
|
||||||
auto UpVal = isl_ast_expr_get_val(UB);
|
int NumberIterations = UpVal.get_num_si();
|
||||||
isl_ast_expr_free(UB);
|
|
||||||
int NumberIterations = isl_val_get_num_si(UpVal);
|
|
||||||
isl_val_free(UpVal);
|
|
||||||
if (NumberIterations < 0)
|
if (NumberIterations < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (Predicate == CmpInst::ICMP_SLT)
|
if (Predicate == CmpInst::ICMP_SLT)
|
||||||
|
@ -418,7 +406,7 @@ void IslNodeBuilder::createMark(__isl_take isl_ast_node *Node) {
|
||||||
if (strcmp(isl_id_get_name(Id), "SIMD") == 0 &&
|
if (strcmp(isl_id_get_name(Id), "SIMD") == 0 &&
|
||||||
isl_ast_node_get_type(Child) == isl_ast_node_for) {
|
isl_ast_node_get_type(Child) == isl_ast_node_for) {
|
||||||
bool Vector = PollyVectorizerChoice == VECTORIZER_POLLY;
|
bool Vector = PollyVectorizerChoice == VECTORIZER_POLLY;
|
||||||
int VectorWidth = getNumberOfIterations(Child);
|
int VectorWidth = getNumberOfIterations(isl::manage_copy(Child));
|
||||||
if (Vector && 1 < VectorWidth && VectorWidth <= 16)
|
if (Vector && 1 < VectorWidth && VectorWidth <= 16)
|
||||||
createForVector(Child, VectorWidth);
|
createForVector(Child, VectorWidth);
|
||||||
else
|
else
|
||||||
|
@ -757,7 +745,7 @@ void IslNodeBuilder::createFor(__isl_take isl_ast_node *For) {
|
||||||
|
|
||||||
if (Vector && IslAstInfo::isInnermostParallel(For) &&
|
if (Vector && IslAstInfo::isInnermostParallel(For) &&
|
||||||
!IslAstInfo::isReductionParallel(For)) {
|
!IslAstInfo::isReductionParallel(For)) {
|
||||||
int VectorWidth = getNumberOfIterations(For);
|
int VectorWidth = getNumberOfIterations(isl::manage_copy(For));
|
||||||
if (1 < VectorWidth && VectorWidth <= 16 && !hasPartialAccesses(For)) {
|
if (1 < VectorWidth && VectorWidth <= 16 && !hasPartialAccesses(For)) {
|
||||||
createForVector(For, VectorWidth);
|
createForVector(For, VectorWidth);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue