From cbe925bd7264c4e14681db16a14805670fd07c71 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Tue, 11 Oct 2016 19:51:20 -0600 Subject: for loop index replacement --- src/omegatools.cc | 10 +++++++--- src/transformations/loop.cc | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/omegatools.cc b/src/omegatools.cc index 6d48a3c..c9f3a9a 100644 --- a/src/omegatools.cc +++ b/src/omegatools.cc @@ -241,12 +241,16 @@ void exp2formula(IR_Code *ir, std::vector v = ir->QueryExpOperand(repr); CHILL_DEBUG_PRINT("IR_OP_MINUS v has %d parts\n", (int) v.size()); - exp2formula(ir, r, f_and, freevars, v[0], e1, side, IR_COND_EQ, true, - uninterpreted_symbols, uninterpreted_symbols_stringrepr); - if (v.size() > 1) { + exp2formula(ir, r, f_and, freevars, v[0], e1, side, IR_COND_EQ, true, + uninterpreted_symbols, uninterpreted_symbols_stringrepr); exp2formula(ir, r, f_and, freevars, v[1], e2, side, IR_COND_EQ, true, uninterpreted_symbols, uninterpreted_symbols_stringrepr); + } else { + exp2formula(ir, r, f_and, freevars, new CG_chillRepr(new chillAST_IntegerLiteral(0)), e1, side, IR_COND_EQ, true, + uninterpreted_symbols, uninterpreted_symbols_stringrepr); + exp2formula(ir, r, f_and, freevars, v[0], e2, side, IR_COND_EQ, true, + uninterpreted_symbols, uninterpreted_symbols_stringrepr); } diff --git a/src/transformations/loop.cc b/src/transformations/loop.cc index b3539a6..8f56be6 100644 --- a/src/transformations/loop.cc +++ b/src/transformations/loop.cc @@ -478,6 +478,9 @@ void Loop::align_loops(std::vector &ir_tree, std::vectorCreateIdent(iname); vars_to_be_replaced.push_back(clp->index()->name()); vars_replacement.push_back(ivar); + ocg->CreateSubstitutedStmt(0,new CG_chillRepr(clp->chillforstmt->getInit()),vars_to_be_replaced,vars_replacement,false); + ocg->CreateSubstitutedStmt(0,new CG_chillRepr(clp->chillforstmt->getInc()),vars_to_be_replaced,vars_replacement,false); + ocg->CreateSubstitutedStmt(0,new CG_chillRepr(clp->chillforstmt->getCond()),vars_to_be_replaced,vars_replacement,false); // FIXME: this breaks abstraction if (clp->step_size()<0) { IR_CONDITION_TYPE cond = clp->conditionoperator; -- cgit v1.2.3-70-g09d2