From ab6f0f2b34b6ad5f44ac291c931a51e90f5d784f Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 3 Mar 2012 16:25:16 +0100 Subject: [PATCH] allow slightly more generic compound increment In particular, don't require the increment to be a constant literal, but any constant expression. Signed-off-by: Sven Verdoolaege --- scan.cc | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/scan.cc b/scan.cc index 2340c7c..d47e572 100644 --- a/scan.cc +++ b/scan.cc @@ -1721,10 +1721,10 @@ bool PetScan::check_binary_increment(BinaryOperator *op, clang::ValueDecl *iv, bool PetScan::check_compound_increment(CompoundAssignOperator *op, clang::ValueDecl *iv, isl_int &inc) { - Expr *lhs, *rhs; + Expr *lhs; DeclRefExpr *ref; bool neg = false; - + isl_pw_aff *val; BinaryOperatorKind opcode; opcode = op->getOpcode(); @@ -1747,29 +1747,18 @@ bool PetScan::check_compound_increment(CompoundAssignOperator *op, return false; } - rhs = op->getRHS(); - - if (rhs->getStmtClass() == Stmt::UnaryOperatorClass) { - UnaryOperator *op = cast(rhs); - if (op->getOpcode() != UO_Minus) { - unsupported(op); - return false; - } - - neg = !neg; - - rhs = op->getSubExpr(); - } + val = extract_affine(op->getRHS()); - if (rhs->getStmtClass() != Stmt::IntegerLiteralClass) { + if (isl_pw_aff_foreach_piece(val, &extract_cst, &inc) < 0) { + isl_pw_aff_free(val); unsupported(op); return false; } - - extract_int(cast(rhs), &inc); if (neg) isl_int_neg(inc, inc); + isl_pw_aff_free(val); + return true; } -- 2.11.4.GIT