[SYSTEMML-1828,1832] New rewrite for merging statement block sequences

This patch introduces a new statement block rewrite for merging DAGs of
subsequent last-level statement blocks. After constant folding and the
removal of unnecessary branches, we often end up with such sequences of
statement blocks. Since many rewrites and operator fusion work on the
granularity of individual DAGs, these unnecessary DAG cuts cause missed
optimization opportunities, especially in the context of operator fusion
(i.e., codegen). We now merge such sequences in awareness of rewrites
that explicitly split DAGs (to create recompilation points).

Apart from the new merge rewrite, this patch also fixes the IPA rewrite
pass that applies static rewrites per IPA round. The repeated
application of the statement block rewrite for injecting spark
checkpoints for variables used read-only in loops introduced redundant
statement blocks and checkpoints. The IPA rewrite pass now explicitly
excludes this rewrite.

Additionally, this patch also modifies the related tests to use
'while(FALSE){}' instead of 'if(1==1){}' as a DAG cut, and fixes some
minor compilation issues that showed up due to the increases
optimization scope.

Overall, there are many scripts and patterns that benefit from these
changes. For example, on 1 epoch of lenet w/ codegen, this patch
improved end-to-end performance from 328s to 297s due to increased
fusion opportunities and fewer compiled spark instructions (70 vs 82).


Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/4b81d0dd
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/4b81d0dd
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/4b81d0dd

Branch: refs/heads/master
Commit: 4b81d0dda6583f0ae96eaa7aa5832005ae5fa8a9
Parents: 0221fbc
Author: Matthias Boehm <mboe...@gmail.com>
Authored: Mon Aug 7 22:21:32 2017 -0700
Committer: Matthias Boehm <mboe...@gmail.com>
Committed: Wed Aug 9 13:52:51 2017 -0700

----------------------------------------------------------------------
 docs/dml-language-reference.md                  |   2 +-
 projects/breast_cancer/MachineLearning.ipynb    |   2 +-
 scripts/nn/test/test.dml                        |   2 +-
 .../hops/ipa/IPAPassApplyStaticHopRewrites.java |   5 +
 .../sysml/hops/rewrite/HopRewriteUtils.java     |  13 ++
 .../sysml/hops/rewrite/ProgramRewriter.java     |  59 ++++---
 .../RewriteAlgebraicSimplificationStatic.java   |   8 +-
 .../rewrite/RewriteForLoopVectorization.java    |  18 +-
 .../RewriteInjectSparkLoopCheckpointing.java    |  26 +--
 .../RewriteMarkLoopVariablesUpdateInPlace.java  |  19 +-
 .../hops/rewrite/RewriteMergeBlockSequence.java | 174 +++++++++++++++++++
 .../RewriteRemoveUnnecessaryBranches.java       |  10 +-
 .../RewriteSplitDagDataDependentOperators.java  |  15 +-
 .../rewrite/RewriteSplitDagUnknownCSVRead.java  |  16 +-
 .../hops/rewrite/StatementBlockRewriteRule.java |  22 ++-
 .../java/org/apache/sysml/lops/compile/Dag.java |  14 +-
 .../sysml/parser/BuiltinFunctionExpression.java |   2 +-
 .../org/apache/sysml/parser/DMLTranslator.java  |   7 +-
 .../sysml/parser/LiveVariableAnalysis.java      |  18 +-
 .../org/apache/sysml/parser/StatementBlock.java |   9 +
 .../org/apache/sysml/parser/VariableSet.java    |  55 +++---
 .../controlprogram/ParForProgramBlock.java      |   2 +-
 .../functions/misc/RewriteMergeBlocksTest.java  |  79 +++++++++
 .../integration/mlcontext/MLContextTest.java    |   2 +-
 .../scripts/applications/ctableStats/ctci.dml   |   6 +-
 .../applications/ctableStats/ctci_odds.dml      |   5 +-
 src/test/scripts/applications/id3/id3.dml       |  33 ++--
 .../applications/mdabivar/MDABivariateStats.dml |   7 +-
 .../validation/CV_LogisticRegression.dml        |  37 +---
 .../validation/CV_MultiClassSVM.sasha.dml       |   6 +-
 .../functions/codegen/SumAdditionChain.dml      |   2 +-
 .../functions/codegen/SumProductChain.dml       |   2 +-
 .../functions/codegen/cellwisetmpl15.dml        |   2 +-
 .../functions/codegen/cellwisetmpl16.dml        |   2 +-
 .../scripts/functions/codegen/cellwisetmpl7.dml |   2 +-
 .../scripts/functions/codegen/cellwisetmpl8.R   |   1 -
 .../scripts/functions/codegen/cellwisetmpl8.dml |   2 +-
 .../scripts/functions/codegen/miscPattern1.dml  |   4 +-
 .../scripts/functions/codegen/miscPattern2.dml  |   2 +-
 .../functions/codegen/multiAggPattern7.dml      |   2 +-
 .../functions/codegen/rowAggPattern17.dml       |   4 +-
 .../functions/codegen/rowAggPattern19.dml       |   2 +-
 .../functions/codegen/rowAggPattern23.dml       |   4 +-
 .../functions/codegen/rowAggPattern24.dml       |   2 +-
 .../functions/codegen/rowAggPattern25.dml       |   2 +-
 .../functions/codegen/rowAggPattern26.dml       |   2 +-
 .../functions/codegen/rowAggPattern27.dml       |   2 +-
 .../functions/codegen/rowAggPattern28.dml       |   2 +-
 .../functions/codegen/rowAggPattern29.dml       |   2 +-
 .../functions/codegen/rowAggPattern30.dml       |   2 +-
 .../codegen/wSparseUnsafeOuterProduct.dml       |   2 +-
 src/test/scripts/functions/codegen/wcemm.dml    |   2 +-
 src/test/scripts/functions/codegen/wdivmm.dml   |   2 +-
 .../scripts/functions/codegen/wdivmmRight.dml   |   2 +-
 .../codegen/wdivmmRightNotranspose.dml          |   2 +-
 .../functions/codegen/wdivmmTransposeOut.dml    |   2 +-
 .../scripts/functions/codegen/wdivmmbasic.dml   |   2 +-
 src/test/scripts/functions/codegen/wsigmoid.dml |   2 +-
 .../scripts/functions/frame/FrameFunction.dml   |   2 +-
 .../functions/frame/FrameMetaReadWrite.dml      |   2 +-
 .../functions/frame/FrameSchemaRead1.dml        |   2 +-
 .../functions/frame/FrameSchemaRead2.dml        |   2 +-
 .../functions/indexing/RowBatchIndexingTest.dml |   2 +-
 ...onstantFoldingScalarVariablePropagation1.dml |   4 +-
 ...onstantFoldingScalarVariablePropagation2.dml |   4 +-
 .../functions/misc/IPANnzPropagation1.dml       |   2 +-
 .../functions/misc/IPANnzPropagation2.dml       |   2 +-
 .../functions/misc/ReadAfterWriteMatrix2.dml    |   2 +-
 .../functions/misc/ReadAfterWriteScalar2.dml    |   2 +-
 .../misc/RewriteCSETransposeScalarMult.dml      |   4 +-
 .../misc/RewriteCSETransposeScalarPow.dml       |   4 +-
 .../misc/RewriteFuseBinaryOpChainTest1.dml      |   2 +-
 .../misc/RewriteFuseBinaryOpChainTest2.dml      |   2 +-
 .../misc/RewriteFuseBinaryOpChainTest3.dml      |   2 +-
 .../misc/RewriteFuseBinaryOpChainTest4.dml      |   2 +-
 .../scripts/functions/misc/RewriteFusedRand.dml |   2 +-
 .../functions/misc/RewriteMergeFunctionCut.R    |  36 ++++
 .../functions/misc/RewriteMergeFunctionCut.dml  |  38 ++++
 .../scripts/functions/misc/RewriteMergeIfCut.R  |  35 ++++
 .../functions/misc/RewriteMergeIfCut.dml        |  31 ++++
 .../misc/RewritePushdownSumBinaryMult.dml       |   2 +-
 .../misc/RewritePushdownSumBinaryMult2.dml      |   2 +-
 .../scripts/functions/misc/dt_change_4c.dml     |   2 +-
 .../scripts/functions/misc/dt_change_4d.dml     |   2 +-
 .../scripts/functions/misc/dt_change_4e.dml     |   2 +-
 .../scripts/functions/misc/dt_change_4f.dml     |   2 +-
 .../functions/misc/functionNoInlining.dml       |  10 +-
 src/test/scripts/functions/parfor/parfor49b.dml |   2 +-
 .../parfor_cdatapartition_leftindexing.dml      |   2 +-
 .../parfor_rdatapartition_leftindexing.dml      |   2 +-
 .../quaternary/WeightedDivMM4MultMinusLeft.dml  |   2 +-
 .../quaternary/WeightedDivMM4MultMinusRight.dml |   2 +-
 .../scripts/functions/recompile/append_nnz.dml  |   3 +-
 .../recompile/constant_propagation_if.R         |   8 +-
 .../recompile/constant_propagation_sb.R         |   9 -
 .../functions/recompile/if_recompile_sparse.dml |   5 +-
 .../functions/recompile/multiple_reads.R        |   9 +-
 .../recompile/remove_empty_potpourri2.dml       |   2 +-
 .../recompile/remove_empty_potpourri3.dml       |   4 +-
 .../recompile/remove_empty_potpourri4.dml       |   4 +-
 .../recompile/rewrite_mapmultchain1.dml         |   4 +-
 .../recompile/rewrite_mapmultchain2.dml         |   4 +-
 src/test/scripts/functions/reorg/Order.dml      |   2 +-
 src/test/scripts/functions/reorg/OrderDyn.dml   |   2 +-
 .../functions/ternary/AAATernaryAggregateC.dml  |   2 +-
 .../functions/ternary/AAATernaryAggregateRC.dml |   2 +-
 .../functions/ternary/ABATernaryAggregateC.dml  |   2 +-
 .../functions/ternary/ABATernaryAggregateRC.dml |   2 +-
 .../functions/ternary/CTableSequenceLeft.dml    |   1 +
 .../functions/ternary/CTableSequenceRight.dml   |   1 +
 .../functions/ternary/TernaryAggregateC.dml     |   2 +-
 .../functions/ternary/TernaryAggregateRC.dml    |   2 +-
 .../functions/transform/FrameCSVReadWrite.dml   |   2 +-
 .../transform/TransformCSVFrameEncodeDecode.dml |   2 +-
 .../transform/TransformFrameEncodeApply.dml     |   2 +-
 .../transform/TransformFrameEncodeDecode.dml    |   2 +-
 .../functions/unary/matrix/PrintTest.dml        |   8 +-
 .../functions/unary/matrix/replace_Infinity.dml |   2 +-
 .../unary/matrix/replace_NInfinity.dml          |   2 +-
 .../functions/unary/matrix/replace_NaN.dml      |   2 +-
 .../functions/updateinplace/updateinplace1.dml  |   4 +-
 .../functions/updateinplace/updateinplace10.dml |   8 +-
 .../functions/misc/ZPackageSuite.java           |   1 +
 123 files changed, 744 insertions(+), 311 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/docs/dml-language-reference.md
----------------------------------------------------------------------
diff --git a/docs/dml-language-reference.md b/docs/dml-language-reference.md
index d5e200d..bd66a42 100644
--- a/docs/dml-language-reference.md
+++ b/docs/dml-language-reference.md
@@ -1782,7 +1782,7 @@ The following DML utilizes the `transformencode()` 
function.
     jspec = read("/user/ml/homes.tfspec_recode2.json", data_type="scalar", 
value_type="string");
     [X, M] = transformencode(target=F1, spec=jspec);
     print(toString(X));
-    if(1==1){}
+    while(FALSE){}
     print(toString(M));
 
 The transformed matrix X and output M are as follows.

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/projects/breast_cancer/MachineLearning.ipynb
----------------------------------------------------------------------
diff --git a/projects/breast_cancer/MachineLearning.ipynb 
b/projects/breast_cancer/MachineLearning.ipynb
index b27116f..1a423b7 100644
--- a/projects/breast_cancer/MachineLearning.ipynb
+++ b/projects/breast_cancer/MachineLearning.ipynb
@@ -683,7 +683,7 @@
    "source": [
     "# script = \"\"\"\n",
     "# f = function(matrix[double] X) return(matrix[double] Y) {\n",
-    "#   if (1==1) {}\n",
+    "#   while(FALSE){}\n",
     "#   a = as.scalar(rand(rows=1, cols=1))\n",
     "#   Y = X * a\n",
     "# }\n",

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/scripts/nn/test/test.dml
----------------------------------------------------------------------
diff --git a/scripts/nn/test/test.dml b/scripts/nn/test/test.dml
index e63639c..06f4632 100644
--- a/scripts/nn/test/test.dml
+++ b/scripts/nn/test/test.dml
@@ -599,7 +599,7 @@ max_pool2d = function() {
   for (padh in 0:3) {
     for (padw in 0:3) {
       print(" - Testing w/ padh="+padh+" & padw="+padw+".")
-      #if (1==1) {}  # force correct printing
+      #while(FALSE){}  # force correct printing
       #print("   - Testing forward")
       [out, Hout, Wout] = max_pool2d::forward(X, C, Hin, Win, Hf, Wf, stride, 
stride, padh, padw)
       [out_simple, Hout_simple, Wout_simple] = max_pool2d_simple::forward(X, 
C, Hin, Win, Hf, Wf,

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/ipa/IPAPassApplyStaticHopRewrites.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/ipa/IPAPassApplyStaticHopRewrites.java 
b/src/main/java/org/apache/sysml/hops/ipa/IPAPassApplyStaticHopRewrites.java
index f436658..923259c 100644
--- a/src/main/java/org/apache/sysml/hops/ipa/IPAPassApplyStaticHopRewrites.java
+++ b/src/main/java/org/apache/sysml/hops/ipa/IPAPassApplyStaticHopRewrites.java
@@ -22,6 +22,7 @@ package org.apache.sysml.hops.ipa;
 
 import org.apache.sysml.hops.HopsException;
 import org.apache.sysml.hops.rewrite.ProgramRewriter;
+import org.apache.sysml.hops.rewrite.RewriteInjectSparkLoopCheckpointing;
 import org.apache.sysml.parser.DMLProgram;
 import org.apache.sysml.parser.LanguageException;
 
@@ -43,7 +44,11 @@ public class IPAPassApplyStaticHopRewrites extends IPAPass
                throws HopsException
        {
                try {
+                       //construct rewriter w/o checkpoint injection to avoid 
redundancy
                        ProgramRewriter rewriter = new ProgramRewriter(true, 
false);
+                       
rewriter.removeStatementBlockRewrite(RewriteInjectSparkLoopCheckpointing.class);
+                       
+                       //rewrite program hop dags and statement blocks
                        rewriter.rewriteProgramHopDAGs(prog);
                } 
                catch (LanguageException ex) {

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java 
b/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
index 3530142..351173f 100644
--- a/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
+++ b/src/main/java/org/apache/sysml/hops/rewrite/HopRewriteUtils.java
@@ -622,6 +622,14 @@ public class HopRewriteUtils
                return ternOp;
        }
        
+       public static DataOp createDataOp(String name, Hop input, DataOpTypes 
type) {
+               DataOp dop = new DataOp(name, input.getDataType(), 
input.getValueType(), input, type, null);
+               dop.setOutputBlocksizes(input.getRowsInBlock(), 
input.getColsInBlock());
+               copyLineNumbers(input, dop);
+               dop.refreshSizeInformation();
+               return dop;
+       }
+       
        public static void setOutputParameters( Hop hop, long rlen, long clen, 
long brlen, long bclen, long nnz ) {
                hop.setDim1( rlen );
                hop.setDim2( clen );
@@ -846,6 +854,11 @@ public class HopRewriteUtils
                return ret;
        }
        
+       public static boolean isData(Hop hop, DataOpTypes type) {
+               return hop instanceof DataOp
+                       && ((DataOp)hop).getDataOpType()==type;
+       }
+       
        public static boolean isBinaryMatrixColVectorOperation(Hop hop) {
                return hop instanceof BinaryOp 
                        && hop.getInput().get(0).getDataType().isMatrix() && 
hop.getInput().get(1).getDataType().isMatrix()

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/ProgramRewriter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/rewrite/ProgramRewriter.java 
b/src/main/java/org/apache/sysml/hops/rewrite/ProgramRewriter.java
index 7c4f861..82eff52 100644
--- a/src/main/java/org/apache/sysml/hops/rewrite/ProgramRewriter.java
+++ b/src/main/java/org/apache/sysml/hops/rewrite/ProgramRewriter.java
@@ -20,6 +20,7 @@
 package org.apache.sysml.hops.rewrite;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -49,7 +50,7 @@ import org.apache.sysml.parser.WhileStatementBlock;
  * program. 
  * 
  */
-public class ProgramRewriter 
+public class ProgramRewriter
 {
        private static final Log LOG = 
LogFactory.getLog(ProgramRewriter.class.getName());
        
@@ -60,17 +61,15 @@ public class ProgramRewriter
        private ArrayList<HopRewriteRule> _dagRuleSet = null;
        private ArrayList<StatementBlockRewriteRule> _sbRuleSet = null;
        
-       static{
+       static {
                // for internal debugging only
                if( LDEBUG ) {
                        Logger.getLogger("org.apache.sysml.hops.rewrite")
                                  .setLevel((Level) Level.DEBUG);
                }
-               
        }
        
-       public ProgramRewriter()
-       {
+       public ProgramRewriter() {
                // by default which is used during initial compile 
                // apply all (static and dynamic) rewrites
                this( true, true );
@@ -107,12 +106,14 @@ public class ProgramRewriter
                        _dagRuleSet.add( new 
RewriteInjectSparkPReadCheckpointing()          ); //dependency: reblock
                        
                        //add statement block rewrite rules
-                       if( OptimizerUtils.ALLOW_BRANCH_REMOVAL )               
        
+                       if( OptimizerUtils.ALLOW_BRANCH_REMOVAL ) {
                                _sbRuleSet.add(  new 
RewriteRemoveUnnecessaryBranches()          ); //dependency: constant folding   
           
+                               _sbRuleSet.add(  new 
RewriteMergeBlockSequence()                 ); //dependency: remove branches
+                       }
                        if( OptimizerUtils.ALLOW_SPLIT_HOP_DAGS )
-                               _sbRuleSet.add(  new 
RewriteSplitDagUnknownCSVRead()             ); //dependency: reblock       
+                               _sbRuleSet.add(  new 
RewriteSplitDagUnknownCSVRead()             ); //dependency: reblock, merge 
blocks 
                        if( 
ConfigurationManager.getCompilerConfigFlag(ConfigType.ALLOW_INDIVIDUAL_SB_SPECIFIC_OPS)
 )
-                               _sbRuleSet.add(  new 
RewriteSplitDagDataDependentOperators()     );
+                               _sbRuleSet.add(  new 
RewriteSplitDagDataDependentOperators()     ); //dependency: merge blocks
                        if( OptimizerUtils.ALLOW_AUTO_VECTORIZATION )
                                _sbRuleSet.add(  new 
RewriteForLoopVectorization()               ); //dependency: reblock (reblockop)
                        _sbRuleSet.add( new 
RewriteInjectSparkLoopCheckpointing(true)        ); //dependency: reblock 
(blocksizes)
@@ -146,8 +147,7 @@ public class ProgramRewriter
         * 
         * @param rewrites the HOP rewrite rules
         */
-       public ProgramRewriter( HopRewriteRule... rewrites )
-       {
+       public ProgramRewriter( HopRewriteRule... rewrites ) {
                //initialize HOP DAG rewrite ruleSet (with fixed rewrite order)
                _dagRuleSet = new ArrayList<HopRewriteRule>();
                for( HopRewriteRule rewrite : rewrites )
@@ -161,8 +161,7 @@ public class ProgramRewriter
         * 
         * @param rewrites the statement block rewrite rules
         */
-       public ProgramRewriter( StatementBlockRewriteRule... rewrites )
-       {
+       public ProgramRewriter( StatementBlockRewriteRule... rewrites ) {
                //initialize HOP DAG rewrite ruleSet (with fixed rewrite order)
                _dagRuleSet = new ArrayList<HopRewriteRule>();
                
@@ -177,8 +176,7 @@ public class ProgramRewriter
         * @param hRewrites HOP rewrite rules
         * @param sbRewrites statement block rewrite rules
         */
-       public ProgramRewriter( ArrayList<HopRewriteRule> hRewrites, 
ArrayList<StatementBlockRewriteRule> sbRewrites )
-       {
+       public ProgramRewriter(ArrayList<HopRewriteRule> hRewrites, 
ArrayList<StatementBlockRewriteRule> sbRewrites) {
                //initialize HOP DAG rewrite ruleSet (with fixed rewrite order)
                _dagRuleSet = new ArrayList<HopRewriteRule>();
                _dagRuleSet.addAll( hRewrites );
@@ -187,6 +185,14 @@ public class ProgramRewriter
                _sbRuleSet.addAll( sbRewrites );
        }
        
+       public void removeHopRewrite(Class<? extends HopRewriteRule> clazz) {
+               _dagRuleSet.removeIf(r -> r.getClass().equals(clazz));
+       }
+       
+       public void removeStatementBlockRewrite(Class<? extends 
StatementBlockRewriteRule> clazz) {
+               _sbRuleSet.removeIf(r -> r.getClass().equals(clazz));
+       }
+       
        public ProgramRewriteStatus rewriteProgramHopDAGs(DMLProgram dmlp) 
                throws LanguageException, HopsException
        {       
@@ -301,21 +307,23 @@ public class ProgramRewriter
                return root;
        }
        
-       public ArrayList<StatementBlock> rewriteStatementBlocks( 
ArrayList<StatementBlock> sbs, ProgramRewriteStatus state ) 
+       public ArrayList<StatementBlock> rewriteStatementBlocks( 
ArrayList<StatementBlock> sbs, ProgramRewriteStatus status ) 
                throws HopsException
        {
                //ensure robustness for calls from outside
-               if( state == null )
-                       state = new ProgramRewriteStatus();
-                               
+               if( status == null )
+                       status = new ProgramRewriteStatus();
                
-               ArrayList<StatementBlock> tmp = new ArrayList<StatementBlock>();
+               //apply rewrite rules to list of statement blocks
+               List<StatementBlock> sbList = sbs; 
+               for( StatementBlockRewriteRule r : _sbRuleSet ) {
+                       sbList = r.rewriteStatementBlocks(sbList, status);
+               }
                
                //rewrite statement blocks (with potential expansion)
-               for( StatementBlock sb : sbs )
-                       tmp.addAll( rewriteStatementBlock(sb, state) );
-               
-               //copy results into original collection
+               ArrayList<StatementBlock> tmp = new ArrayList<StatementBlock>();
+               for( StatementBlock sb : sbList )
+                       tmp.addAll( rewriteStatementBlock(sb, status) );
                sbs.clear();
                sbs.addAll( tmp );
                
@@ -362,9 +370,8 @@ public class ProgramRewriter
                        status.setInParforContext(prestatus);
                }
                
-               //apply rewrite rules
-               for( StatementBlockRewriteRule r : _sbRuleSet )
-               {
+               //apply rewrite rules to individual statement blocks
+               for( StatementBlockRewriteRule r : _sbRuleSet ) {
                        ArrayList<StatementBlock> tmp = new 
ArrayList<StatementBlock>();                        
                        for( StatementBlock sbc : ret )
                                tmp.addAll( r.rewriteStatementBlock(sbc, 
status) );

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
index 53359cc..63c6772 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteAlgebraicSimplificationStatic.java
@@ -1647,11 +1647,9 @@ public class RewriteAlgebraicSimplificationStatic 
extends HopRewriteRule
                                inputargs.put("cast", new LiteralOp(false));
                        
                                //create new hop
-                               ParameterizedBuiltinOp pbop = new 
ParameterizedBuiltinOp("tmp", DataType.MATRIX, ValueType.DOUBLE, 
-                                               ParamBuiltinOp.REXPAND, 
inputargs);
-                               pbop.setOutputBlocksizes(hi.getRowsInBlock(), 
hi.getColsInBlock());
-                               pbop.refreshSizeInformation();
-               
+                               ParameterizedBuiltinOp pbop = HopRewriteUtils
+                                       .createParameterizedBuiltinOp(trgt, 
inputargs, ParamBuiltinOp.REXPAND);
+                               
                                //relink new hop into original position
                                HopRewriteUtils.replaceChildReference(parent, 
hi, pbop, pos);
                                hi = pbop;

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteForLoopVectorization.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteForLoopVectorization.java 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteForLoopVectorization.java
index 7154b36..fdcf96b 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteForLoopVectorization.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteForLoopVectorization.java
@@ -19,7 +19,8 @@
 
 package org.apache.sysml.hops.rewrite;
 
-import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.sysml.hops.AggUnaryOp;
 import org.apache.sysml.hops.BinaryOp;
@@ -49,17 +50,14 @@ import org.apache.sysml.parser.Expression.DataType;
  */
 public class RewriteForLoopVectorization extends StatementBlockRewriteRule
 {
-
        private static final OpOp2[] MAP_SCALAR_AGGREGATE_SOURCE_OPS = new 
OpOp2[]{OpOp2.PLUS, OpOp2.MULT, OpOp2.MIN, OpOp2.MAX};
        private static final AggOp[] MAP_SCALAR_AGGREGATE_TARGET_OPS = new 
AggOp[]{AggOp.SUM,  AggOp.PROD, AggOp.MIN, AggOp.MAX};
        
        
        @Override
-       public ArrayList<StatementBlock> rewriteStatementBlock(StatementBlock 
sb, ProgramRewriteStatus state)
+       public List<StatementBlock> rewriteStatementBlock(StatementBlock sb, 
ProgramRewriteStatus state)
                throws HopsException 
        {
-               ArrayList<StatementBlock> ret = new ArrayList<StatementBlock>();
-               
                if( sb instanceof ForStatementBlock )
                {
                        ForStatementBlock fsb = (ForStatementBlock) sb;
@@ -96,9 +94,13 @@ public class RewriteForLoopVectorization extends 
StatementBlockRewriteRule
                
                //if no rewrite applied sb is the original for loop otherwise a 
last level statement block
                //that includes the equivalent vectorized operations.
-               ret.add( sb );
-               
-               return ret;
+               return Arrays.asList(sb);
+       }
+       
+       @Override
+       public List<StatementBlock> rewriteStatementBlocks(List<StatementBlock> 
sbs, 
+                       ProgramRewriteStatus sate) throws HopsException {
+               return sbs;
        }
        
        private StatementBlock vectorizeScalarAggregate( StatementBlock sb, 
StatementBlock csb, Hop from, Hop to, Hop increment, String itervar ) 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteInjectSparkLoopCheckpointing.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteInjectSparkLoopCheckpointing.java
 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteInjectSparkLoopCheckpointing.java
index 6b46ee2..1c59e6e 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteInjectSparkLoopCheckpointing.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteInjectSparkLoopCheckpointing.java
@@ -20,6 +20,8 @@
 package org.apache.sysml.hops.rewrite;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.sysml.hops.DataOp;
 import org.apache.sysml.hops.Hop;
@@ -47,21 +49,17 @@ public class RewriteInjectSparkLoopCheckpointing extends 
StatementBlockRewriteRu
 {
        private boolean _checkCtx = false;
        
-       public RewriteInjectSparkLoopCheckpointing(boolean checkParForContext)
-       {
+       public RewriteInjectSparkLoopCheckpointing(boolean checkParForContext) {
                _checkCtx = checkParForContext;
        }
        
        @Override
-       public ArrayList<StatementBlock> rewriteStatementBlock(StatementBlock 
sb, ProgramRewriteStatus status)
+       public List<StatementBlock> rewriteStatementBlock(StatementBlock sb, 
ProgramRewriteStatus status)
                throws HopsException 
        {
-               ArrayList<StatementBlock> ret = new ArrayList<StatementBlock>();
-               
-               if( !OptimizerUtils.isSparkExecutionMode() ) 
-               {
-                       ret.add(sb); // nothing to do here
-                       return ret; //return original statement block
+               if( !OptimizerUtils.isSparkExecutionMode() ) {
+                       // nothing to do here, return original statement block
+                       return Arrays.asList(sb);
                }
                
                //1) We currently add checkpoint operations without information 
about the global program structure,
@@ -69,6 +67,7 @@ public class RewriteInjectSparkLoopCheckpointing extends 
StatementBlockRewriteRu
                //2) Also, we do not take size information into account right 
now. This means that all candidates
                //are checkpointed even if they are only used by CP operations.
                
+               ArrayList<StatementBlock> ret = new ArrayList<>();
                int blocksize = status.getBlocksize(); //block size set by 
reblock rewrite
                
                //apply rewrite for while, for, and parfor (the decision for 
parfor loop bodies is deferred until parfor
@@ -101,7 +100,7 @@ public class RewriteInjectSparkLoopCheckpointing extends 
StatementBlockRewriteRu
                                        long dim2 = (dat instanceof 
IndexedIdentifier) ? ((IndexedIdentifier)dat).getOrigDim2() : dat.getDim2();
                                        DataOp tread = new DataOp(var, 
DataType.MATRIX, ValueType.DOUBLE, DataOpTypes.TRANSIENTREAD, 
                                                                    
dat.getFilename(), dim1, dim2, dat.getNnz(), blocksize, blocksize);
-                                       tread.setRequiresCheckpoint( true );
+                                       tread.setRequiresCheckpoint(true);
                                        DataOp twrite = new DataOp(var, 
DataType.MATRIX, ValueType.DOUBLE, tread, DataOpTypes.TRANSIENTWRITE, null);
                                        
HopRewriteUtils.setOutputParameters(twrite, dim1, dim2, blocksize, blocksize, 
dat.getNnz());                                    
                                        hops.add(twrite);
@@ -111,6 +110,7 @@ public class RewriteInjectSparkLoopCheckpointing extends 
StatementBlockRewriteRu
                                sb0.set_hops(hops);
                                sb0.setLiveIn(livein);
                                sb0.setLiveOut(liveout);
+                               sb0.setSplitDag(true);
                                ret.add(sb0);
                                
                                //maintain rewrite status
@@ -123,4 +123,10 @@ public class RewriteInjectSparkLoopCheckpointing extends 
StatementBlockRewriteRu
                
                return ret;
        }
+       
+       @Override
+       public List<StatementBlock> rewriteStatementBlocks(List<StatementBlock> 
sbs, 
+                       ProgramRewriteStatus sate) throws HopsException {
+               return sbs;
+       }
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteMarkLoopVariablesUpdateInPlace.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteMarkLoopVariablesUpdateInPlace.java
 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteMarkLoopVariablesUpdateInPlace.java
index 6e3621f..a61dd43 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteMarkLoopVariablesUpdateInPlace.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteMarkLoopVariablesUpdateInPlace.java
@@ -20,6 +20,8 @@
 package org.apache.sysml.hops.rewrite;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.sysml.api.DMLScript;
 import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
@@ -47,16 +49,14 @@ import org.apache.sysml.parser.Expression.DataType;
 public class RewriteMarkLoopVariablesUpdateInPlace extends 
StatementBlockRewriteRule
 {
        @Override
-       public ArrayList<StatementBlock> rewriteStatementBlock(StatementBlock 
sb, ProgramRewriteStatus status)
+       public List<StatementBlock> rewriteStatementBlock(StatementBlock sb, 
ProgramRewriteStatus status)
                throws HopsException 
        {
-               ArrayList<StatementBlock> ret = new ArrayList<StatementBlock>();
-               
                if( DMLScript.rtplatform == RUNTIME_PLATFORM.HADOOP
                        || DMLScript.rtplatform == RUNTIME_PLATFORM.SPARK )
                {
-                       ret.add(sb); // nothing to do here
-                       return ret; //return original statement block
+                       // nothing to do here, return original statement block
+                       return Arrays.asList(sb);
                }
                
                if( sb instanceof WhileStatementBlock || sb instanceof 
ForStatementBlock ) //incl parfor 
@@ -86,8 +86,7 @@ public class RewriteMarkLoopVariablesUpdateInPlace extends 
StatementBlockRewrite
                }
                        
                //return modified statement block
-               ret.add(sb);
-               return ret;
+               return Arrays.asList(sb);
        }
        
        private boolean rIsApplicableForUpdateInPlace( 
ArrayList<StatementBlock> sbs, String varname ) 
@@ -150,4 +149,10 @@ public class RewriteMarkLoopVariablesUpdateInPlace extends 
StatementBlockRewrite
                
                return validLix;
        }
+       
+       @Override
+       public List<StatementBlock> rewriteStatementBlocks(List<StatementBlock> 
sbs, 
+                       ProgramRewriteStatus sate) throws HopsException {
+               return sbs;
+       }
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteMergeBlockSequence.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteMergeBlockSequence.java 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteMergeBlockSequence.java
new file mode 100644
index 0000000..746e536
--- /dev/null
+++ b/src/main/java/org/apache/sysml/hops/rewrite/RewriteMergeBlockSequence.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sysml.hops.rewrite;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.sysml.hops.FunctionOp;
+import org.apache.sysml.hops.Hop;
+import org.apache.sysml.hops.Hop.DataOpTypes;
+import org.apache.sysml.hops.HopsException;
+import org.apache.sysml.parser.ForStatementBlock;
+import org.apache.sysml.parser.FunctionStatementBlock;
+import org.apache.sysml.parser.IfStatementBlock;
+import org.apache.sysml.parser.StatementBlock;
+import org.apache.sysml.parser.VariableSet;
+import org.apache.sysml.parser.WhileStatementBlock;
+
+/**
+ * Rule: Simplify program structure by merging sequences of last-level
+ * statement blocks in order to create optimization opportunities.
+ * 
+ */
+public class RewriteMergeBlockSequence extends StatementBlockRewriteRule
+{
+       private ProgramRewriter rewriter = new ProgramRewriter(
+               new RewriteCommonSubexpressionElimination(true));
+       
+       @Override
+       public List<StatementBlock> rewriteStatementBlock(StatementBlock sb, 
+                       ProgramRewriteStatus state) throws HopsException {
+               return Arrays.asList(sb);
+       }
+       
+       @Override
+       public List<StatementBlock> rewriteStatementBlocks(List<StatementBlock> 
sbs, 
+                       ProgramRewriteStatus sate) throws HopsException 
+       {
+               if( sbs == null || sbs.isEmpty() )
+                       return sbs;
+               
+               //execute binary merging iterations until fixpoint 
+               ArrayList<StatementBlock> tmpList = new ArrayList<>(sbs);
+               boolean merged = true;
+               while( merged ) {
+                       merged = false;
+                       for( int i=0; i<tmpList.size()-1; i++ ) {
+                               StatementBlock sb1 = tmpList.get(i);
+                               StatementBlock sb2 = tmpList.get(i+1);
+                               if( isLastLevelStatementBlock(sb1) && 
isLastLevelStatementBlock(sb2) 
+                                       && !hasFunctionOpRoot(sb1) && 
!sb1.isSplitDag() && !sb2.isSplitDag() 
+                                       && sb2.getBeginLine()!=34 ) 
+                               {
+                                       ArrayList<Hop> sb1Hops = sb1.get_hops();
+                                       ArrayList<Hop> sb2Hops = sb2.get_hops();
+                                       
+                                       //determine transient read inputs s2 
+                                       Hop.resetVisitStatus(sb2Hops);
+                                       HashMap<String,Hop> treads = new 
HashMap<>();
+                                       HashMap<String,Hop> twrites = new 
HashMap<>();
+                                       for( Hop root : sb2Hops )
+                                               
rCollectTransientReadWrites(root, treads, twrites);
+                                       Hop.resetVisitStatus(sb2Hops);
+                                       
+                                       //merge hop dags of s1 and s2
+                                       Hop.resetVisitStatus(sb1Hops);
+                                       for( Hop root : sb1Hops ) {
+                                               //connect transient writes s1 
and reads s2
+                                               if( 
HopRewriteUtils.isData(root, DataOpTypes.TRANSIENTWRITE) 
+                                                       && 
treads.containsKey(root.getName()) ) {
+                                                       //rewire transient 
write and transient read
+                                                       Hop tread = 
treads.get(root.getName());
+                                                       Hop in = 
root.getInput().get(0);
+                                                       for( Hop parent : new 
ArrayList<Hop>(tread.getParent()) )
+                                                               
HopRewriteUtils.replaceChildReference(parent, tread, in);
+                                                       
HopRewriteUtils.removeAllChildReferences(root);
+                                                       //add transient write 
if necessary
+                                                       if( 
!twrites.containsKey(root.getName()) 
+                                                               && 
sb2.liveOut().containsVariable(root.getName()) ) {
+                                                               
sb2Hops.add(HopRewriteUtils.createDataOp(
+                                                                       
root.getName(), in, DataOpTypes.TRANSIENTWRITE));
+                                                       }
+                                               }
+                                               //add remaining roots from s1 
to s2
+                                               else if( 
!(HopRewriteUtils.isData(root, DataOpTypes.TRANSIENTWRITE)
+                                                       && 
twrites.containsKey(root.getName())) ) {
+                                                       sb2Hops.add(root);
+                                               }
+                                       }
+                                       Hop.resetVisitStatus(sb2Hops);
+                                       
+                                       //run common-subexpression elimination
+                                       rewriter.rewriteHopDAGs(sb2Hops, new 
ProgramRewriteStatus());
+                                       
+                                       //modify live variable sets of s2
+                                       sb2.setLiveIn(sb1.liveIn()); //liveOut 
remains unchanged
+                                       
sb2.setGen(VariableSet.minus(VariableSet.union(sb1.getGen(), sb2.getGen()), 
sb1.getKill()));
+                                       
sb2.setKill(VariableSet.union(sb1.getKill(), sb2.getKill()));
+                                       
sb2.setReadVariables(VariableSet.union(sb1.variablesRead(), 
sb2.variablesRead()));
+                                       
sb2.setUpdatedVariables(VariableSet.union(sb1.variablesUpdated(), 
sb2.variablesUpdated()));
+                                       
+                                       LOG.debug("Applied 
mergeStatementBlockSequences "
+                                                       + "(blocks of lines 
"+sb1.getBeginLine()+"-"+sb1.getEndLine()
+                                                       +" and 
"+sb2.getBeginLine()+"-"+sb2.getEndLine()+").");
+                                       
+                                       //modify line numbers of s2
+                                       sb2.setBeginLine(sb1.getBeginLine());
+                                       
sb2.setBeginColumn(sb1.getBeginColumn());
+                                       
+                                       //remove sb1 from list of statement 
blocks
+                                       tmpList.remove(i);
+                                       merged = true;
+                                       break; //for
+                               }
+                       }
+               }
+               
+               return tmpList;
+       }
+       
+       private void rCollectTransientReadWrites(Hop current, HashMap<String, 
Hop> treads, HashMap<String, Hop> twrites) {
+               if( current.isVisited() )
+                       return;
+               //process nodes recursively
+               for( Hop c : current.getInput() )
+                       rCollectTransientReadWrites(c, treads, twrites);
+               //collect all transient reads
+               if( HopRewriteUtils.isData(current, DataOpTypes.TRANSIENTREAD) )
+                       treads.put(current.getName(), current);
+               else if( HopRewriteUtils.isData(current, 
DataOpTypes.TRANSIENTWRITE) )
+                       twrites.put(current.getName(), current);
+               else if( current instanceof FunctionOp ) {
+                       for( String output : 
((FunctionOp)current).getOutputVariableNames() )
+                               twrites.put(output, null); //only name lookup
+               }
+               current.setVisited();
+       }
+       
+       private static boolean hasFunctionOpRoot(StatementBlock sb) 
+                       throws HopsException {
+               if( sb == null || sb.get_hops() == null )
+                       return false;
+               boolean ret = false;
+               for( Hop root : sb.get_hops() )
+                       ret |= (root instanceof FunctionOp);
+               return ret;
+       }
+       
+       private static boolean isLastLevelStatementBlock(StatementBlock sb) {
+               return !((sb instanceof FunctionStatementBlock)
+                       || (sb instanceof WhileStatementBlock)
+                       || (sb instanceof IfStatementBlock)
+                       || (sb instanceof ForStatementBlock)); //incl parfor
+       }
+}

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemoveUnnecessaryBranches.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemoveUnnecessaryBranches.java
 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemoveUnnecessaryBranches.java
index fa99948..27e1dd3 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemoveUnnecessaryBranches.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteRemoveUnnecessaryBranches.java
@@ -20,6 +20,7 @@
 package org.apache.sysml.hops.rewrite;
 
 import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.sysml.hops.Hop;
 import org.apache.sysml.hops.HopsException;
@@ -36,9 +37,8 @@ import org.apache.sysml.parser.StatementBlock;
  */
 public class RewriteRemoveUnnecessaryBranches extends StatementBlockRewriteRule
 {
-
        @Override
-       public ArrayList<StatementBlock> rewriteStatementBlock(StatementBlock 
sb, ProgramRewriteStatus state)
+       public List<StatementBlock> rewriteStatementBlock(StatementBlock sb, 
ProgramRewriteStatus state)
                throws HopsException 
        {
                ArrayList<StatementBlock> ret = new ArrayList<StatementBlock>();
@@ -81,4 +81,10 @@ public class RewriteRemoveUnnecessaryBranches extends 
StatementBlockRewriteRule
                
                return ret;
        }
+       
+       @Override
+       public List<StatementBlock> rewriteStatementBlocks(List<StatementBlock> 
sbs, 
+                       ProgramRewriteStatus sate) throws HopsException {
+               return sbs;
+       }
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagDataDependentOperators.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagDataDependentOperators.java
 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagDataDependentOperators.java
index 6c2fda9..351cf87 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagDataDependentOperators.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagDataDependentOperators.java
@@ -22,6 +22,7 @@ package org.apache.sysml.hops.rewrite;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.List;
 
 import org.apache.sysml.api.DMLScript;
 import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
@@ -70,7 +71,7 @@ public class RewriteSplitDagDataDependentOperators extends 
StatementBlockRewrite
        private static IDSequence _seq = new IDSequence();
        
        @Override
-       public ArrayList<StatementBlock> rewriteStatementBlock(StatementBlock 
sb, ProgramRewriteStatus state)
+       public List<StatementBlock> rewriteStatementBlock(StatementBlock sb, 
ProgramRewriteStatus state)
                throws HopsException 
        {
                //DAG splits not required for forced single node
@@ -184,21 +185,23 @@ public class RewriteSplitDagDataDependentOperators 
extends StatementBlockRewrite
                                        sb1.liveOut().addVariable(varname, new 
DataIdentifier(diVar));
                                        sb.liveIn().addVariable(varname, new 
DataIdentifier(diVar));
                                }
-               
+                               
                                //ensure disjoint operators across DAGs 
(prevent replicated operations)
                                handleReplicatedOperators( sb1hops, 
sb.get_hops(), sb1.liveOut(), sb.liveIn() );
                                
                                //deep copy new dag (in order to prevent any 
dangling references)
                                
sb1.set_hops(Recompiler.deepCopyHopsDag(sb1hops));
                                sb1.updateRecompilationFlag();
+                               sb1.setSplitDag(true); //avoid later merge by 
other rewrites
                                
                                //recursive application of rewrite rule (in 
case of multiple data dependent operators
                                //with data dependencies in between each other)
-                               ArrayList<StatementBlock> tmp = 
rewriteStatementBlock( sb1, state);
+                               List<StatementBlock> tmp = 
rewriteStatementBlock(sb1, state);
                                
                                //add new statement blocks to output
                                ret.addAll(tmp); //statement block with data 
dependent hops
                                ret.add(sb); //statement block with remaining 
hops
+                               sb.setSplitDag(true); //avoid later merge by 
other rewrites
                        }
                        catch(Exception ex)
                        {
@@ -466,4 +469,10 @@ public class RewriteSplitDagDataDependentOperators extends 
StatementBlockRewrite
                
                hop.setVisited();
        }
+       
+       @Override
+       public List<StatementBlock> rewriteStatementBlocks(List<StatementBlock> 
sbs, 
+                       ProgramRewriteStatus sate) throws HopsException {
+               return sbs;
+       }
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagUnknownCSVRead.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagUnknownCSVRead.java
 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagUnknownCSVRead.java
index 2e9847a..6d9942f 100644
--- 
a/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagUnknownCSVRead.java
+++ 
b/src/main/java/org/apache/sysml/hops/rewrite/RewriteSplitDagUnknownCSVRead.java
@@ -21,6 +21,7 @@ package org.apache.sysml.hops.rewrite;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 import org.apache.sysml.api.DMLScript;
 import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
@@ -44,14 +45,13 @@ import 
org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType;
  */
 public class RewriteSplitDagUnknownCSVRead extends StatementBlockRewriteRule
 {
-
        @Override
-       public ArrayList<StatementBlock> rewriteStatementBlock(StatementBlock 
sb, ProgramRewriteStatus state)
+       public List<StatementBlock> rewriteStatementBlock(StatementBlock sb, 
ProgramRewriteStatus state)
                throws HopsException 
        {
                //DAG splits not required for forced single node
                if( DMLScript.rtplatform == RUNTIME_PLATFORM.SINGLE_NODE )
-                       return new ArrayList<StatementBlock>(Arrays.asList(sb));
+                       return Arrays.asList(sb);
                
                ArrayList<StatementBlock> ret = new ArrayList<StatementBlock>();
                
@@ -121,6 +121,7 @@ public class RewriteSplitDagUnknownCSVRead extends 
StatementBlockRewriteRule
                                sb1.updateRecompilationFlag();
                                ret.add(sb1); //statement block with csv 
reblocks
                                ret.add(sb); //statement block with remaining 
hops
+                               sb.setSplitDag(true); //avoid later merge by 
other rewrites
                        }
                        catch(Exception ex)
                        {
@@ -137,8 +138,13 @@ public class RewriteSplitDagUnknownCSVRead extends 
StatementBlockRewriteRule
                return ret;
        }
        
-       private void collectCSVReadHopsUnknownSize( ArrayList<Hop> roots, 
ArrayList<Hop> cand )
-       {
+       @Override
+       public List<StatementBlock> rewriteStatementBlocks(List<StatementBlock> 
sbs, 
+                       ProgramRewriteStatus sate) throws HopsException {
+               return sbs;
+       }
+       
+       private void collectCSVReadHopsUnknownSize( ArrayList<Hop> roots, 
ArrayList<Hop> cand ) {
                if( roots == null )
                        return;
                

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/hops/rewrite/StatementBlockRewriteRule.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/rewrite/StatementBlockRewriteRule.java 
b/src/main/java/org/apache/sysml/hops/rewrite/StatementBlockRewriteRule.java
index 3d4b105..eba2276 100644
--- a/src/main/java/org/apache/sysml/hops/rewrite/StatementBlockRewriteRule.java
+++ b/src/main/java/org/apache/sysml/hops/rewrite/StatementBlockRewriteRule.java
@@ -19,7 +19,7 @@
 
 package org.apache.sysml.hops.rewrite;
 
-import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,19 +34,31 @@ import org.apache.sysml.parser.StatementBlock;
  */
 public abstract class StatementBlockRewriteRule 
 {
-
        protected static final Log LOG = 
LogFactory.getLog(StatementBlockRewriteRule.class.getName());
-               
+       
        /**
         * Handle an arbitrary statement block. Specific type constraints have 
to be ensured
-        * within the individual rewrites.
+        * within the individual rewrites. If a rewrite does not apply to 
individual blocks, it 
+        * should simply return the input block.
         * 
         * @param sb statement block
         * @param sate program rewrite status
         * @return list of statement blocks
         * @throws HopsException if HopsException occurs
         */
-       public abstract ArrayList<StatementBlock> rewriteStatementBlock( 
StatementBlock sb, ProgramRewriteStatus sate ) 
+       public abstract List<StatementBlock> 
rewriteStatementBlock(StatementBlock sb, ProgramRewriteStatus sate) 
                throws HopsException;
        
+       /**
+        * Handle a list of statement blocks. Specific type constraints have to 
be ensured
+        * within the individual rewrites. If a rewrite does not require 
sequence access, it 
+        * should simply return the input list of statement blocks.
+        * 
+        * @param sbs list of statement blocks
+        * @param sate program rewrite status
+        * @return list of statement blocks
+        * @throws HopsException if HopsException occurs
+        */
+       public abstract List<StatementBlock> 
rewriteStatementBlocks(List<StatementBlock> sbs, ProgramRewriteStatus sate) 
+               throws HopsException;
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/lops/compile/Dag.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/lops/compile/Dag.java 
b/src/main/java/org/apache/sysml/lops/compile/Dag.java
index 1da1ba6..8673fc9 100644
--- a/src/main/java/org/apache/sysml/lops/compile/Dag.java
+++ b/src/main/java/org/apache/sysml/lops/compile/Dag.java
@@ -3157,17 +3157,21 @@ public class Dag<N extends Lop>
                                                
MRJobLineNumbers.add(node._beginLine);
                                        }
                                        nodeIndexMapping.put(node, 
output_index);
-                                       return output_index;
                                }
 
                                return output_index;
                        }
-                       else if (inputIndices.size() == 4) {
+                       else if (inputIndices.size() == 4 || 
inputIndices.size() == 5) {
                                int output_index = start_index[0];
                                start_index[0]++;
-                               
otherInstructionsReducer.add(node.getInstructions(
-                                               inputIndices.get(0), 
inputIndices.get(1),
-                                               inputIndices.get(2), 
inputIndices.get(3), output_index));
+                               if( inputIndices.size() == 4 )
+                                       
otherInstructionsReducer.add(node.getInstructions(
+                                                       inputIndices.get(0), 
inputIndices.get(1),
+                                                       inputIndices.get(2), 
inputIndices.get(3), output_index));
+                               else
+                                       
otherInstructionsReducer.add(node.getInstructions(
+                                                       inputIndices.get(0), 
inputIndices.get(1), inputIndices.get(2), 
+                                                       inputIndices.get(3), 
inputIndices.get(4), output_index));
                                if(DMLScript.ENABLE_DEBUG_MODE) {
                                        MRJobLineNumbers.add(node._beginLine);
                                }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java 
b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
index 3ffc2d9..aa26f2d 100644
--- a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
+++ b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
@@ -1080,7 +1080,7 @@ public class BuiltinFunctionExpression extends 
DataIdentifier
                        //set output characteristics
                        output.setDataType(id.getDataType());
                        output.setDimensions(id.getDim1(), id2.getDim2());
-                       output.setBlockDimensions(id.getRowsInBlock(), 
id.getColumnsInBlock()); 
+                       output.setBlockDimensions(id.getRowsInBlock(), 
id.getColumnsInBlock());
                        break;
                
                case BIAS_ADD:

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/parser/DMLTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/DMLTranslator.java 
b/src/main/java/org/apache/sysml/parser/DMLTranslator.java
index 818815d..731b300 100644
--- a/src/main/java/org/apache/sysml/parser/DMLTranslator.java
+++ b/src/main/java/org/apache/sysml/parser/DMLTranslator.java
@@ -1337,8 +1337,7 @@ public class DMLTranslator
                                                Hop.OpOp1 op = Hop.OpOp1.PRINT;
                                                Expression source = 
ps.getExpressions().get(0);
                                                Hop ae = 
processExpression(source, target, ids);
-                                               Hop printHop = new 
UnaryOp(target.getName(), target.getDataType(), target.getValueType(), op,
-                                                               ae);
+                                               Hop printHop = new 
UnaryOp(target.getName(), target.getDataType(), target.getValueType(), op, ae);
                                                
printHop.setAllPositions(current.getFilename(), current.getBeginLine(), 
current.getBeginColumn(), current.getEndLine(),
                                                                
current.getEndColumn());
                                                output.add(printHop);
@@ -1346,11 +1345,11 @@ public class DMLTranslator
                                                Hop.OpOp1 op = Hop.OpOp1.STOP;
                                                Expression source = 
ps.getExpressions().get(0);
                                                Hop ae = 
processExpression(source, target, ids);
-                                               Hop stopHop = new 
UnaryOp(target.getName(), target.getDataType(), target.getValueType(), op,
-                                                               ae);
+                                               Hop stopHop = new 
UnaryOp(target.getName(), target.getDataType(), target.getValueType(), op, ae);
                                                
stopHop.setAllPositions(current.getFilename(), current.getBeginLine(), 
current.getBeginColumn(), current.getEndLine(),
                                                                
current.getEndColumn());
                                                output.add(stopHop);
+                                               sb.setSplitDag(true); //avoid 
merge
                                        } else if (ptype == PRINTTYPE.PRINTF) {
                                                List<Expression> expressions = 
ps.getExpressions();
                                                Hop[] inHops = new 
Hop[expressions.size()];

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/parser/LiveVariableAnalysis.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/LiveVariableAnalysis.java 
b/src/main/java/org/apache/sysml/parser/LiveVariableAnalysis.java
index 9133e33..cd13cb4 100644
--- a/src/main/java/org/apache/sysml/parser/LiveVariableAnalysis.java
+++ b/src/main/java/org/apache/sysml/parser/LiveVariableAnalysis.java
@@ -22,8 +22,6 @@ package org.apache.sysml.parser;
 
 public abstract class LiveVariableAnalysis 
 {
-
-               
        VariableSet _read;
        VariableSet _updated;
        VariableSet _gen;
@@ -59,14 +57,26 @@ public abstract class LiveVariableAnalysis
                return _kill;
        }
        
-       public void setLiveOut(VariableSet lo){
+       public VariableSet getGen(){
+               return _gen;
+       }
+       
+       public void setLiveOut(VariableSet lo) {
                _liveOut = lo;
        }
        
-       public void setLiveIn(VariableSet li){
+       public void setLiveIn(VariableSet li) {
                _liveIn = li;
        }
        
+       public void setKill(VariableSet ki) {
+               _kill = ki;
+       }
+       
+       public void setGen(VariableSet ge) {
+               _gen = ge;
+       }
+       
        public void setUpdatedVariables( VariableSet vars ){
                _updated = vars;
        }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/parser/StatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/StatementBlock.java 
b/src/main/java/org/apache/sysml/parser/StatementBlock.java
index 79c7a9a..d5cf1d7 100644
--- a/src/main/java/org/apache/sysml/parser/StatementBlock.java
+++ b/src/main/java/org/apache/sysml/parser/StatementBlock.java
@@ -56,6 +56,7 @@ public class StatementBlock extends LiveVariableAnalysis
 
        private ArrayList<String> _updateInPlaceVars = null;
        private boolean _requiresRecompile = false;
+       private boolean _splitDag = false;
 
        public StatementBlock() {
                _dmlProg = null;
@@ -146,6 +147,14 @@ public class StatementBlock extends LiveVariableAnalysis
                }
                return true;
        }
+       
+       public void setSplitDag(boolean flag) {
+               _splitDag = flag;
+       }
+       
+       public boolean isSplitDag() {
+               return _splitDag;
+       }
 
 
     public boolean isMergeableFunctionCallBlock(DMLProgram dmlProg) throws 
LanguageException{

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/parser/VariableSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/VariableSet.java 
b/src/main/java/org/apache/sysml/parser/VariableSet.java
index b1f5067..16ad08b 100644
--- a/src/main/java/org/apache/sysml/parser/VariableSet.java
+++ b/src/main/java/org/apache/sysml/parser/VariableSet.java
@@ -19,48 +19,37 @@
 
 package org.apache.sysml.parser;
 
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Set;
 
 public class VariableSet 
 {
-       
        private HashMap<String,DataIdentifier> _variables;
        
-       public VariableSet(){
+       public VariableSet() {
                _variables = new HashMap<String,DataIdentifier>();
        }
        
-       public VariableSet( VariableSet vs )
-       {
+       public VariableSet( VariableSet vs ) {
                _variables = new HashMap<String,DataIdentifier>();
-               
-               if (vs != null) {
-                       HashMap<String,DataIdentifier> vars = vs.getVariables();
-                       _variables.putAll(vars);
-               }               
+               if (vs != null)
+                       _variables.putAll(vs.getVariables());
        }
        
-       public void addVariable(String name, DataIdentifier id)
-       {
+       public void addVariable(String name, DataIdentifier id) {
                _variables.put(name,id);
        }
        
-       public void addVariables(VariableSet vs)
-       {
-               if (vs != null) {
-                       HashMap<String,DataIdentifier> vars = vs.getVariables();
-                       _variables.putAll(vars);
-               }
+       public void addVariables(VariableSet vs) {
+               if (vs != null)
+                       _variables.putAll(vs.getVariables());
        }
        
-       public void removeVariables(VariableSet vs)
-       {
-               if( vs != null ){
-                       Set<String> vars = vs.getVariables().keySet();
-                       for (String var : vars)
+       public void removeVariables(VariableSet vs) {
+               if( vs != null )
+                       for( String var : vs.getVariables().keySet() )
                                _variables.remove(var);
-               }
        }
 
        public boolean containsVariable(String name){
@@ -79,12 +68,20 @@ public class VariableSet
                return _variables;
        }
        
-       public String toString(){
-               StringBuilder sb = new StringBuilder();
-               for (String var : _variables.keySet()){
-                       sb.append(var + ",");
-               }
-               return sb.toString();
+       public String toString() {
+               return Arrays.toString(
+                       _variables.keySet().toArray());
+       }
+       
+       public static VariableSet union(VariableSet vs1, VariableSet vs2) {
+               VariableSet ret = new VariableSet(vs1);
+               ret.addVariables(vs2);
+               return ret;
        }
        
+       public static VariableSet minus(VariableSet vs1, VariableSet vs2) {
+               VariableSet ret = new VariableSet(vs1);
+               ret.removeVariables(vs2);
+               return ret;
+       }
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/main/java/org/apache/sysml/runtime/controlprogram/ParForProgramBlock.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/runtime/controlprogram/ParForProgramBlock.java 
b/src/main/java/org/apache/sysml/runtime/controlprogram/ParForProgramBlock.java
index 169c3bb..9f225c6 100644
--- 
a/src/main/java/org/apache/sysml/runtime/controlprogram/ParForProgramBlock.java
+++ 
b/src/main/java/org/apache/sysml/runtime/controlprogram/ParForProgramBlock.java
@@ -549,7 +549,7 @@ public class ParForProgramBlock extends ForProgramBlock
        @Override       
        public void execute(ExecutionContext ec)
                throws DMLRuntimeException
-       {       
+       {
                ParForStatementBlock sb = 
(ParForStatementBlock)getStatementBlock();
                
                // add the iterable predicate variable to the variable set

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteMergeBlocksTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteMergeBlocksTest.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteMergeBlocksTest.java
new file mode 100644
index 0000000..4a14ba6
--- /dev/null
+++ 
b/src/test/java/org/apache/sysml/test/integration/functions/misc/RewriteMergeBlocksTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sysml.test.integration.functions.misc;
+
+import java.util.HashMap;
+import org.junit.Test;
+import org.junit.Assert;
+import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex;
+import org.apache.sysml.test.integration.AutomatedTestBase;
+import org.apache.sysml.test.integration.TestConfiguration;
+import org.apache.sysml.test.utils.TestUtils;
+
+public class RewriteMergeBlocksTest extends AutomatedTestBase 
+{
+       private static final String TEST_NAME1 = "RewriteMergeIfCut"; //full 
merge
+       private static final String TEST_NAME2 = "RewriteMergeFunctionCut"; 
//only input merge
+
+       private static final String TEST_DIR = "functions/misc/";
+       private static final String TEST_CLASS_DIR = TEST_DIR + 
RewriteMergeBlocksTest.class.getSimpleName() + "/";
+       
+       private static final double eps = Math.pow(10,-10);
+       
+       @Override
+       public void setUp() {
+               TestUtils.clearAssertionInformation();
+               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[]{"R"}));
+               addTestConfiguration(TEST_NAME2, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[]{"R"}));
+       }
+       
+       @Test
+       public void testIfCutMerge() {
+               testRewriteMerge(TEST_NAME1);
+       }
+       
+       @Test
+       public void testFunctionCutMerge() {
+               testRewriteMerge(TEST_NAME2);
+       }
+       
+       private void testRewriteMerge(String testname)
+       {       
+               TestConfiguration config = getTestConfiguration(testname);
+               loadTestConfiguration(config);
+               
+               String HOME = SCRIPT_DIR + TEST_DIR;
+               fullDMLScriptName = HOME + testname + ".dml";
+               programArgs = new String[]{ "-explain","-stats","-args", 
output("R") };
+               
+               fullRScriptName = HOME + testname + ".R";
+               rCmd = getRCmd(expectedDir());
+
+               runTest(true, false, null, -1); 
+               runRScript(true); 
+               
+               //compare outputs and check for compiled mmchain as proof for 
merge blocks 
+               HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
+               HashMap<CellIndex, Double> rfile  = readRMatrixFromFS("R");
+               TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", 
"Stat-R");
+               Assert.assertTrue(testname.equals(TEST_NAME1) == 
+                       heavyHittersContainsSubString("mmchain"));
+       }       
+}

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/java/org/apache/sysml/test/integration/mlcontext/MLContextTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/mlcontext/MLContextTest.java 
b/src/test/java/org/apache/sysml/test/integration/mlcontext/MLContextTest.java
index 88d1a28..b08f5b9 100644
--- 
a/src/test/java/org/apache/sysml/test/integration/mlcontext/MLContextTest.java
+++ 
b/src/test/java/org/apache/sysml/test/integration/mlcontext/MLContextTest.java
@@ -2652,7 +2652,7 @@ public class MLContextTest extends MLContextTestBase {
        public void testFunctionNoReturnValueForceFunctionCallDML() {
                System.out.println("MLContextTest - function with no return 
value, force function call DML");
 
-               String s = "hello=function(){\nif(1==1){};\nprint('no return 
value, force function call');\n}\nhello();";
+               String s = "hello=function(){\nwhile(FALSE){};\nprint('no 
return value, force function call');\n}\nhello();";
                Script script = dml(s);
                setExpectedStdOut("no return value, force function call");
                ml.execute(script);

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/applications/ctableStats/ctci.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/applications/ctableStats/ctci.dml 
b/src/test/scripts/applications/ctableStats/ctci.dml
index f545138..efed917 100644
--- a/src/test/scripts/applications/ctableStats/ctci.dml
+++ b/src/test/scripts/applications/ctableStats/ctci.dml
@@ -88,9 +88,9 @@ iBlock = 0;
 for (iLabel in 1:numLabels)
 {
     if (iLabel != nullLabel) {
-        if (1==1) {
-            print ("Processing label " + iLabel + ":");
-        }
+        print ("Processing label " + iLabel + ":");
+        while(FALSE){}
+        
         fCol = 1 + iBlock * 100;
         HeadMtx [iLabel, 1] = fCol + zero;
         cntPartitionsWithLabel = CT [, iLabel];

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/applications/ctableStats/ctci_odds.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/applications/ctableStats/ctci_odds.dml 
b/src/test/scripts/applications/ctableStats/ctci_odds.dml
index f13a25b..ba1b981 100644
--- a/src/test/scripts/applications/ctableStats/ctci_odds.dml
+++ b/src/test/scripts/applications/ctableStats/ctci_odds.dml
@@ -82,9 +82,8 @@ for (iLabel in 1:numLabels)
 {
     if (iLabel != nullLabel)
     {
-        if (1==1) {
-            print ("Processing label " + iLabel + ":");
-        }
+        print ("Processing label " + iLabel + ":");
+        
         for (iPartition in 1:numPartitions)
         {
             idx = idx + 1;

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/applications/id3/id3.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/applications/id3/id3.dml 
b/src/test/scripts/applications/id3/id3.dml
index 69b59e1..66a39f2 100644
--- a/src/test/scripts/applications/id3/id3.dml
+++ b/src/test/scripts/applications/id3/id3.dml
@@ -93,9 +93,9 @@
 id3_learn = function(Matrix[Double] X, Matrix[Double] y, Matrix[Double] 
X_subset, Matrix[Double] attributes, Double minsplit) return (Matrix[Double] 
nodes, Matrix[Double] edges){
        hist_labels = aggregate(target=X_subset, groups=y, fn="sum")
        
-       if (1==1) {
-         print(" ");
-       }
+       print(" ");
+       while(FALSE){}
+       
        #go through the histogram to compute the number of labels
        #with non-zero samples
        #and to pull out the most popular label
@@ -182,20 +182,17 @@ id3_learn = function(Matrix[Double] X, Matrix[Double] y, 
Matrix[Double] X_subset
                
                attr_vals = X[,best_attr]
                attr_domain = aggregate(target=X_subset, groups=attr_vals, 
fn="sum")
-               if (1==1) {
-                       print(" ");
-               }
+               print(" ");
+               while(FALSE){}
 
                new_attributes = attributes
                new_attributes[best_attr, 1] = 0
                
                max_sz_subtree = 2*sum(X_subset)
-               sz1 = 0
-               sz2 = 0
-               if(1==1){
-                       sz2 = nrow(attr_domain)
-                       sz1 = sz2*max_sz_subtree
-               }
+               sz2 = nrow(attr_domain)
+               sz1 = sz2*max_sz_subtree
+               while(FALSE){}
+               
                tempNodeStore = matrix(0, rows=2, cols=sz1)
                tempEdgeStore = matrix(0, rows=3, cols=sz1)
                numSubtreeNodes = matrix(0, rows=sz2, cols=1)
@@ -225,17 +222,17 @@ id3_learn = function(Matrix[Double] X, Matrix[Double] y, 
Matrix[Double] X_subset
                num_edges_in_subtrees = sum(numSubtreeEdges)
                
                #creating root node
-               if(1==1){
-                       sz = 1+num_nodes_in_subtrees
-               }
+               sz = 1+num_nodes_in_subtrees
+               while(FALSE){}
+               
                nodes = matrix(0, rows=sz, cols=2)
                nodes[1,1] = best_attr
                numNodes = 1
                
                #edges from root to children
-               if(1==1){
-                       sz = sum(numSubtreeNodes > 0) + num_edges_in_subtrees
-               }
+               sz = sum(numSubtreeNodes > 0) + num_edges_in_subtrees
+               while(FALSE){}
+               
                edges = matrix(1, rows=sz, cols=3)
                numEdges = 0
                for(i6 in 1:nrow(attr_domain)){

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/applications/mdabivar/MDABivariateStats.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/applications/mdabivar/MDABivariateStats.dml 
b/src/test/scripts/applications/mdabivar/MDABivariateStats.dml
index 1a47440..faf29b6 100644
--- a/src/test/scripts/applications/mdabivar/MDABivariateStats.dml
+++ b/src/test/scripts/applications/mdabivar/MDABivariateStats.dml
@@ -122,10 +122,9 @@ parfor(i3 in 1:nrow(feature_indices), check=0){
                        [pVal, contingencyTable, rowMarginals, colMarginals] = 
bivar_cc(labels, feature)
                        stats[feature_index2,1] = pVal
                        
-                       sz3=1
-                       if(1==1){
-                               sz3 = 
nrow(contingencyTable)*ncol(contingencyTable)
-                       }
+                       sz3 = nrow(contingencyTable)*ncol(contingencyTable)
+                       while(FALSE){}
+                       
                        contingencyTableLabelValues = matrix(0, rows=1, 
cols=sz3)
                        contingencyTableFeatureValues = matrix(0, rows=1, 
cols=sz3)
                        

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/applications/validation/CV_LogisticRegression.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/applications/validation/CV_LogisticRegression.dml 
b/src/test/scripts/applications/validation/CV_LogisticRegression.dml
index 6e765e3..f072845 100644
--- a/src/test/scripts/applications/validation/CV_LogisticRegression.dml
+++ b/src/test/scripts/applications/validation/CV_LogisticRegression.dml
@@ -470,21 +470,7 @@ printFoldStatistics = function (Matrix[double] stats ) 
return( Integer err )
     stats_avg = round (colMeans(stats) * 10000.0) / 10000.0;
     stats_max = round (colMaxs (stats) * 10000.0) / 10000.0;
     stats_min = round (colMins (stats) * 10000.0) / 10000.0;
-/*    
-    print ("Training Data, Model-estimated statistics:");
-    print ("    True Positives:  Min = " + as.scalar (stats_min [1,  1]) + ",  
Avg = " + as.scalar (stats_avg [1,  1]) + ",  Max = " + as.scalar (stats_max 
[1,  1]));
-    print ("   False Positives:  Min = " + as.scalar (stats_min [1,  2]) + ",  
Avg = " + as.scalar (stats_avg [1,  2]) + ",  Max = " + as.scalar (stats_max 
[1,  2]));
-    print ("    True Negatives:  Min = " + as.scalar (stats_min [1,  3]) + ",  
Avg = " + as.scalar (stats_avg [1,  3]) + ",  Max = " + as.scalar (stats_max 
[1,  3]));
-    print ("   False Negatives:  Min = " + as.scalar (stats_min [1,  4]) + ",  
Avg = " + as.scalar (stats_avg [1,  4]) + ",  Max = " + as.scalar (stats_max 
[1,  4]));
-    print ("       Precision %:  Min = " + as.scalar (stats_min [1,  5]) + ",  
Avg = " + as.scalar (stats_avg [1,  5]) + ",  Max = " + as.scalar (stats_max 
[1,  5]));
-    print ("Recall (Sensit-y)%:  Min = " + as.scalar (stats_min [1,  6]) + ",  
Avg = " + as.scalar (stats_avg [1,  6]) + ",  Max = " + as.scalar (stats_max 
[1,  6]));
-    print ("     Specificity %:  Min = " + as.scalar (stats_min [1,  7]) + ",  
Avg = " + as.scalar (stats_avg [1,  7]) + ",  Max = " + as.scalar (stats_max 
[1,  7]));
-    print ("      Value - Cost:  Min = " + as.scalar (stats_min [1,  8]) + ",  
Avg = " + as.scalar (stats_avg [1,  8]) + ",  Max = " + as.scalar (stats_max 
[1,  8]));
-    print (" ");
-    if (1==1) {
-      print(" ")
-    }
-*/
+
     print ("Training Data, Label comparison statistics:");
     print ("    True Positives:  Min = " + as.scalar (stats_min [1, 11]) + ",  
Avg = " + as.scalar (stats_avg [1, 11]) + ",  Max = " + as.scalar (stats_max 
[1, 11]));
     print ("   False Positives:  Min = " + as.scalar (stats_min [1, 12]) + ",  
Avg = " + as.scalar (stats_avg [1, 12]) + ",  Max = " + as.scalar (stats_max 
[1, 12]));
@@ -495,24 +481,9 @@ printFoldStatistics = function (Matrix[double] stats ) 
return( Integer err )
     print ("     Specificity %:  Min = " + as.scalar (stats_min [1, 17]) + ",  
Avg = " + as.scalar (stats_avg [1, 17]) + ",  Max = " + as.scalar (stats_max 
[1, 17]));
     print ("      Value - Cost:  Min = " + as.scalar (stats_min [1, 18]) + ",  
Avg = " + as.scalar (stats_avg [1, 18]) + ",  Max = " + as.scalar (stats_max 
[1, 18]));
     print (" ");
-    if (1==1) {
-      print(" ")
-    }
-/*
-    print ("TEST Data, Model-estimated statistics:");
-    print ("    True Positives:  Min = " + as.scalar (stats_min [1, 21]) + ",  
Avg = " + as.scalar (stats_avg [1, 21]) + ",  Max = " + as.scalar (stats_max 
[1, 21]));
-    print ("   False Positives:  Min = " + as.scalar (stats_min [1, 22]) + ",  
Avg = " + as.scalar (stats_avg [1, 22]) + ",  Max = " + as.scalar (stats_max 
[1, 22]));
-    print ("    True Negatives:  Min = " + as.scalar (stats_min [1, 23]) + ",  
Avg = " + as.scalar (stats_avg [1, 23]) + ",  Max = " + as.scalar (stats_max 
[1, 23]));
-    print ("   False Negatives:  Min = " + as.scalar (stats_min [1, 24]) + ",  
Avg = " + as.scalar (stats_avg [1, 24]) + ",  Max = " + as.scalar (stats_max 
[1, 24]));
-    print ("       Precision %:  Min = " + as.scalar (stats_min [1, 25]) + ",  
Avg = " + as.scalar (stats_avg [1, 25]) + ",  Max = " + as.scalar (stats_max 
[1, 25]));
-    print ("Recall (Sensit-y)%:  Min = " + as.scalar (stats_min [1, 26]) + ",  
Avg = " + as.scalar (stats_avg [1, 26]) + ",  Max = " + as.scalar (stats_max 
[1, 26]));
-    print ("     Specificity %:  Min = " + as.scalar (stats_min [1, 27]) + ",  
Avg = " + as.scalar (stats_avg [1, 27]) + ",  Max = " + as.scalar (stats_max 
[1, 27]));
-    print ("      Value - Cost:  Min = " + as.scalar (stats_min [1, 28]) + ",  
Avg = " + as.scalar (stats_avg [1, 28]) + ",  Max = " + as.scalar (stats_max 
[1, 28]));
-    print (" ");
-    if (1==1) {
-      print(" ")
-    }
-*/
+    print(" ")
+    while(FALSE){}
+
     print ("TEST Data, Label comparison statistics:");
     print ("    True Positives:  Min = " + as.scalar (stats_min [1, 31]) + ",  
Avg = " + as.scalar (stats_avg [1, 31]) + ",  Max = " + as.scalar (stats_max 
[1, 31]));
     print ("   False Positives:  Min = " + as.scalar (stats_min [1, 32]) + ",  
Avg = " + as.scalar (stats_avg [1, 32]) + ",  Max = " + as.scalar (stats_max 
[1, 32]));

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/applications/validation/CV_MultiClassSVM.sasha.dml
----------------------------------------------------------------------
diff --git 
a/src/test/scripts/applications/validation/CV_MultiClassSVM.sasha.dml 
b/src/test/scripts/applications/validation/CV_MultiClassSVM.sasha.dml
index 0943f1a..c0326ff 100644
--- a/src/test/scripts/applications/validation/CV_MultiClassSVM.sasha.dml
+++ b/src/test/scripts/applications/validation/CV_MultiClassSVM.sasha.dml
@@ -314,9 +314,9 @@ printFoldStatistics = function (Matrix[double] stats ) 
return( Integer err )
     print ("     Precision %:  Min = " + as.scalar (stats_min [1, 15]) + ",  
Avg = " + as.scalar (stats_avg [1, 15]) + ",  Max = " + as.scalar (stats_max 
[1, 15]));
 
     print (" ");
-    if (1==1) {
-      print(" ")
-    }
+    print(" ")
+    while(FALSE){}
+    
     print ("TEST Data, Label comparison statistics:");
     print ("    True Matches:  Min = " + as.scalar (stats_min [1, 31]) + ",  
Avg = " + as.scalar (stats_avg [1, 31]) + ",  Max = " + as.scalar (stats_max 
[1, 31]));
     print ("   False Matches:  Min = " + as.scalar (stats_min [1, 32]) + ",  
Avg = " + as.scalar (stats_avg [1, 32]) + ",  Max = " + as.scalar (stats_max 
[1, 32]));

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/SumAdditionChain.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/SumAdditionChain.dml 
b/src/test/scripts/functions/codegen/SumAdditionChain.dml
index 87b0143..db4acf6 100644
--- a/src/test/scripts/functions/codegen/SumAdditionChain.dml
+++ b/src/test/scripts/functions/codegen/SumAdditionChain.dml
@@ -23,7 +23,7 @@ X = read($1)
 Y = X + 2;
 Z = X + 3;
 
-if(1==1){}
+while(FALSE){}
 
 R = as.matrix(sum(X+Y+Z));
 write(R, $2)

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/SumProductChain.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/SumProductChain.dml 
b/src/test/scripts/functions/codegen/SumProductChain.dml
index 2b65ee1..b899689 100644
--- a/src/test/scripts/functions/codegen/SumProductChain.dml
+++ b/src/test/scripts/functions/codegen/SumProductChain.dml
@@ -23,7 +23,7 @@ X = read($1)
 Y = X + 2;
 Z = X + 3;
 
-if(1==1){}
+while(FALSE){}
 
 R = as.matrix(sum(X*Y*Z));
 write(R, $2)

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/cellwisetmpl15.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/cellwisetmpl15.dml 
b/src/test/scripts/functions/codegen/cellwisetmpl15.dml
index e543671..5f95196 100644
--- a/src/test/scripts/functions/codegen/cellwisetmpl15.dml
+++ b/src/test/scripts/functions/codegen/cellwisetmpl15.dml
@@ -20,7 +20,7 @@
 #-------------------------------------------------------------
 
 X = matrix(seq(7, 1100*200+6), 1100, 200);
-if(1==1){}
+while(FALSE){}
 
 R = colMins(2*log(X));
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/cellwisetmpl16.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/cellwisetmpl16.dml 
b/src/test/scripts/functions/codegen/cellwisetmpl16.dml
index 1fb07b5..c3da55f 100644
--- a/src/test/scripts/functions/codegen/cellwisetmpl16.dml
+++ b/src/test/scripts/functions/codegen/cellwisetmpl16.dml
@@ -20,7 +20,7 @@
 #-------------------------------------------------------------
 
 X = matrix(seq(7, 1100*200+6), 1100, 200);
-if(1==1){}
+while(FALSE){}
 
 R = colSums(2*log(X));
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/cellwisetmpl7.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/cellwisetmpl7.dml 
b/src/test/scripts/functions/codegen/cellwisetmpl7.dml
index 6b2afd3..6124969 100644
--- a/src/test/scripts/functions/codegen/cellwisetmpl7.dml
+++ b/src/test/scripts/functions/codegen/cellwisetmpl7.dml
@@ -24,7 +24,7 @@ Y = seq(6, 1006);
 
 Z = X + Y - 7 + abs(X);
 R = as.scalar(t(Z) %*% Z)
-if(1==1){}
+while(FALSE){}
 
 print(R)
 write(R, $1)

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/cellwisetmpl8.R
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/cellwisetmpl8.R 
b/src/test/scripts/functions/codegen/cellwisetmpl8.R
index 9ad506b..20ea454 100644
--- a/src/test/scripts/functions/codegen/cellwisetmpl8.R
+++ b/src/test/scripts/functions/codegen/cellwisetmpl8.R
@@ -26,7 +26,6 @@ library("Matrix")
 X = matrix(1, 1002, 23);
 Y = seq(1, 1002);
 X[100:900,] = matrix(0, 801, 23); 
-if(1==1){}
 
 R = X * ((X + 7.7) * (Y%*%matrix(1,1,23)));
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/cellwisetmpl8.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/cellwisetmpl8.dml 
b/src/test/scripts/functions/codegen/cellwisetmpl8.dml
index d330d70..9fe6b5d 100644
--- a/src/test/scripts/functions/codegen/cellwisetmpl8.dml
+++ b/src/test/scripts/functions/codegen/cellwisetmpl8.dml
@@ -22,7 +22,7 @@
 X = matrix(1, rows=1002, cols=23);
 Y = seq(1, 1002);
 X[100:900,] = matrix(0, rows=801, cols=23); 
-if(1==1){}
+while(FALSE){}
 
 R = X * ((X + 7.7) * Y);
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/miscPattern1.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/miscPattern1.dml 
b/src/test/scripts/functions/codegen/miscPattern1.dml
index 6c8dbd9..528e8eb 100644
--- a/src/test/scripts/functions/codegen/miscPattern1.dml
+++ b/src/test/scripts/functions/codegen/miscPattern1.dml
@@ -25,11 +25,11 @@ U = matrix(3, 1100, 10);
 V = matrix(4, 2200, 10)
 X[4:900,3:1000] = matrix(0, 897, 998);
 
-if(1==1){}
+while(FALSE){}
 
 R1 = Y + (X * U%*%t(V));
 
-if(1==1){}
+while(FALSE){}
 
 R2 = as.matrix(sum(R1));
 write(R2, $1)

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/miscPattern2.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/miscPattern2.dml 
b/src/test/scripts/functions/codegen/miscPattern2.dml
index 8c2a35b..d6a5c6c 100644
--- a/src/test/scripts/functions/codegen/miscPattern2.dml
+++ b/src/test/scripts/functions/codegen/miscPattern2.dml
@@ -22,7 +22,7 @@
 X = matrix(1, 2340, 7);
 Y = matrix(2, 2340, 7);
 
-if(1==1){}
+while(FALSE){}
 
 Z = abs(exp((log(exp(X + Y))+7)/7));
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/multiAggPattern7.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/multiAggPattern7.dml 
b/src/test/scripts/functions/codegen/multiAggPattern7.dml
index 3306fd8..e727533 100644
--- a/src/test/scripts/functions/codegen/multiAggPattern7.dml
+++ b/src/test/scripts/functions/codegen/multiAggPattern7.dml
@@ -21,7 +21,7 @@
 
 X = seq(1,15);
 Y = seq(2,16);
-if(1==1){}
+while(FALSE){}
 
 r1 = t(X)%*%X;
 r2 = t(X)%*%Y;

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern17.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern17.dml 
b/src/test/scripts/functions/codegen/rowAggPattern17.dml
index 1a7ce93..b8d026b 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern17.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern17.dml
@@ -23,10 +23,10 @@ X = matrix(seq(1,1500), 150, 10);
 P = matrix(2, nrow(X), 2);
 Y0 = matrix(1, nrow(X), 1);
 max_y = max(Y0)+1;
-if(1==1){}
+while(FALSE){}
 Y = table(seq(1,nrow(Y0)), Y0, nrow(Y0), max_y);
 
-if(1==1){} #recompile w/o knowing K
+while(FALSE){} #recompile w/o knowing K
 K = ncol(Y)-1;
 R = t(X) %*% (P [, 1:K] - Y [, 1:K]);
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern19.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern19.dml 
b/src/test/scripts/functions/codegen/rowAggPattern19.dml
index cb1fa3d..b78c5c4 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern19.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern19.dml
@@ -21,7 +21,7 @@
 
 LT = matrix(1, 1500, 2);
 Y = matrix(2, 1500, 2);
-if(1==1) {}
+while(FALSE){}
   
 LT = LT - rowMaxs (LT);
 exp_LT = exp (LT);

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern23.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern23.dml 
b/src/test/scripts/functions/codegen/rowAggPattern23.dml
index 4aafd0f..ba6606f 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern23.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern23.dml
@@ -23,7 +23,7 @@
 X = matrix(seq(1,3000), 60, 50);
 Y = seq(1,60);
 Xw = seq(2,61);
-if(1==1){}
+while(FALSE){}
 
 out = 1 - Y * Xw
 sv = (out > 0)
@@ -31,7 +31,7 @@ out = sv * out
 obj = 0.5 * sum(out * out)
 g_new = t(X) %*% (out * Y)
 
-if(1==1){}
+while(FALSE){}
 R = as.matrix(obj + sum(g_new));
 
 write(R, $1)

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern24.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern24.dml 
b/src/test/scripts/functions/codegen/rowAggPattern24.dml
index 200d552..70ac431 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern24.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern24.dml
@@ -23,7 +23,7 @@
 X = matrix(seq(1,6000)/6000, 600, 10);
 w = matrix(seq(1,2400)/2400, 600, 4);
 v = matrix(seq(1,40)/40, 10, 4);
-if(1==1){}
+while(FALSE){}
 
 R = t(X) %*% (w * (X %*% v));
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern25.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern25.dml 
b/src/test/scripts/functions/codegen/rowAggPattern25.dml
index fa8775e..de601a4 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern25.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern25.dml
@@ -22,7 +22,7 @@
 
 X = matrix(seq(1,6000), 600, 10);
 C = matrix(seq(1,40), 4, 10);
-if(1==1){}
+while(FALSE){}
 
 R = -2 * (X %*% t(C)) + t(rowSums(C^2))
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern26.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern26.dml 
b/src/test/scripts/functions/codegen/rowAggPattern26.dml
index f84b556..2c40e26 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern26.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern26.dml
@@ -21,7 +21,7 @@
 
 X = matrix(seq(1,6000), 600, 10);
 P = matrix(seq(1,3000), 600, 5)
-if(1==1){}
+while(FALSE){}
 
 R = t(P) %*% X;
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern27.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern27.dml 
b/src/test/scripts/functions/codegen/rowAggPattern27.dml
index c5254c2..825f83b 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern27.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern27.dml
@@ -22,7 +22,7 @@
 
 X = matrix(seq(1,6000)/6000, 600, 10);
 v = matrix(seq(1,40)/40, 10, 4);
-if(1==1){}
+while(FALSE){}
 
 R = t(X) %*% (X %*% v);
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern28.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern28.dml 
b/src/test/scripts/functions/codegen/rowAggPattern28.dml
index bc40685..f7a6df5 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern28.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern28.dml
@@ -22,7 +22,7 @@
 
 X = matrix(seq(1,6000)/6000, 600, 10);
 C = matrix(seq(1,40)/40, 4, 10);
-if(1==1){}
+while(FALSE){}
 
 D =  -2 * (X %*% t(C)) + t(rowSums (C ^ 2));
 P = (D <= rowMins (D));

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern29.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern29.dml 
b/src/test/scripts/functions/codegen/rowAggPattern29.dml
index 236d449..1081b50 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern29.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern29.dml
@@ -21,7 +21,7 @@
 
 
 X = matrix(seq(1,6000)/6000, 600, 10);
-if(1==1){}
+while(FALSE){}
 
 R = as.matrix(sum(rowMins(X)));
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/rowAggPattern30.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern30.dml 
b/src/test/scripts/functions/codegen/rowAggPattern30.dml
index 60e5e54..7df215d 100644
--- a/src/test/scripts/functions/codegen/rowAggPattern30.dml
+++ b/src/test/scripts/functions/codegen/rowAggPattern30.dml
@@ -25,7 +25,7 @@ ssX_V = matrix(seq(1,40), 10, 4)/40;
 P = matrix(seq(1,3000), 600, 5)/3000;
 K = 4;
 
-if(1==1){}
+while(FALSE){}
 Q = P[,1:K] * (X %*% ssX_V);
 R = t(X) %*% (Q - P[,1:K] * rowSums(Q));
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/wSparseUnsafeOuterProduct.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/wSparseUnsafeOuterProduct.dml 
b/src/test/scripts/functions/codegen/wSparseUnsafeOuterProduct.dml
index 61748f6..d209591 100644
--- a/src/test/scripts/functions/codegen/wSparseUnsafeOuterProduct.dml
+++ b/src/test/scripts/functions/codegen/wSparseUnsafeOuterProduct.dml
@@ -24,7 +24,7 @@ X[100:900,] = matrix(0, rows=801, cols=2000)
 U = matrix( 4, rows=1000, cols=10)
 V = matrix( 5, rows=2000, cols=10)
 
-if(1==1){}
+while(FALSE){}
 
 S = X+1/(U%*%t(V));
 write(S,$1)

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/wcemm.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/wcemm.dml 
b/src/test/scripts/functions/codegen/wcemm.dml
index 32ff880..c83bc04 100644
--- a/src/test/scripts/functions/codegen/wcemm.dml
+++ b/src/test/scripts/functions/codegen/wcemm.dml
@@ -22,7 +22,7 @@
 X= read($2)
 U= matrix( 1, rows=2000, cols=10)
 V= matrix( 2, rows=2000, cols=10)
-if(1==1){}
+while(FALSE){}
 
 eps = 0.1
 S= sum(X*log(U%*%t(V)+eps))

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/wdivmm.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/wdivmm.dml 
b/src/test/scripts/functions/codegen/wdivmm.dml
index 0a3d324..083bb19 100644
--- a/src/test/scripts/functions/codegen/wdivmm.dml
+++ b/src/test/scripts/functions/codegen/wdivmm.dml
@@ -22,7 +22,7 @@
 X = matrix( 3, rows=4000, cols=2000)
 U = matrix( 4, rows=4000, cols=10)
 V = matrix( 5, rows=2000, cols=10)
-if(1==1){}
+while(FALSE){}
 eps = 0.1
 S= t(t(U) %*% (X/(U%*%t(V)+eps)))
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/wdivmmRight.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/wdivmmRight.dml 
b/src/test/scripts/functions/codegen/wdivmmRight.dml
index 97a5baf..6c6549d 100644
--- a/src/test/scripts/functions/codegen/wdivmmRight.dml
+++ b/src/test/scripts/functions/codegen/wdivmmRight.dml
@@ -23,7 +23,7 @@ X = matrix( 3, rows=4000, cols=2000)
 U = matrix( 4, rows=4000, cols=10)
 V = matrix( 5, rows=2000, cols=10)
 
-if(1==1){}
+while(FALSE){}
 
 eps = 0.1
 S= (X/(U%*%t(V)))%*%V

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/wdivmmRightNotranspose.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/wdivmmRightNotranspose.dml 
b/src/test/scripts/functions/codegen/wdivmmRightNotranspose.dml
index 730e526..6138684 100644
--- a/src/test/scripts/functions/codegen/wdivmmRightNotranspose.dml
+++ b/src/test/scripts/functions/codegen/wdivmmRightNotranspose.dml
@@ -23,7 +23,7 @@ X = matrix( 3, rows=4000, cols=2000)
 U = matrix( 4, rows=4000, cols=10)
 V = matrix( 5, rows=10, cols=2000)
 
-if(1==1){}
+while(FALSE){}
 
 eps = 0.1
 S= (X/((U%*%V)+eps))%*%t(V)

http://git-wip-us.apache.org/repos/asf/systemml/blob/4b81d0dd/src/test/scripts/functions/codegen/wdivmmTransposeOut.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/wdivmmTransposeOut.dml 
b/src/test/scripts/functions/codegen/wdivmmTransposeOut.dml
index 2e1f40f..570116e 100644
--- a/src/test/scripts/functions/codegen/wdivmmTransposeOut.dml
+++ b/src/test/scripts/functions/codegen/wdivmmTransposeOut.dml
@@ -23,7 +23,7 @@ X = matrix( 3, rows=4000, cols=2000)
 U = matrix( 4, rows=4000, cols=10)
 V = matrix( 5, rows=10, cols=2000)
 
-if(1==1){}
+while(FALSE){}
 
 eps = 0.1
 S= (t(U) %*% (X/((U%*%V)+eps)))

Reply via email to