continue; }     int upperSJCount = 0; boolean shouldAbort = false; for (int j=0; j<sj1.size() && !(shouldAbort); j++) { if (sj1.get(j) instanceof SIRSplitJoin) { upperSJCount++; if (upperSJCount>1) { shouldAbort = true; } } } if (shouldAbort) {
    public static boolean removeMatchingSyncPoints(SIRPipeline pipe) {	boolean madeChange = false;	for (int i=0; i<pipe.size()-1; i++) {	    // look for adjacent splitjoins	    if (pipe.get(i) instanceof SIRSplitJoin && 		pipe.get(i+1) instanceof SIRSplitJoin) {		// look for matching weights		SIRSplitJoin sj1 = (SIRSplitJoin)pipe.get(i);		SIRSplitJoin sj2 = (SIRSplitJoin)pipe.get(i+1);		// diff number of weights, can't do anything		if (sj1.size()!=sj2.size() || sj1.size()==1) {		    continue;		}		// can't do it if second splitjoin is a duplicate		if (sj2.getSplitter().getType()==SIRSplitType.DUPLICATE) {		    continue;		}		// get weights		int[] w1 = sj1.getJoiner().getWeights();		int[] w2 = sj2.getSplitter().getWeights();		// test for equality		boolean equal = true;		for (int j=0; j<w1.length; j++) {		    if (w1[j]!=w2[j]) {			equal = false;		    }		}		// don't do anything if a weight is unequal		if (!equal) {		    continue;		}		// otherwise, we have a case where we can combine the		// streams.		madeChange = true;		// make new splitjoin to replace sj1 and sj2		SIRSplitJoin sj3 =  new SIRSplitJoin(pipe,						     sj1.getIdent()+"_"+sj2.getIdent());		sj3.setInit(SIRStream.makeEmptyInit());		sj3.setSplitter(sj1.getSplitter());		sj3.setJoiner(sj2.getJoiner());		// add children		for (int j=0; j<sj1.size(); j++) {		    SIRPipeline child = new SIRPipeline(sj1,							sj1.get(j).getIdent()+"_"+sj2.get(j).getIdent());		    child.setInit(SIRStream.makeEmptyInit());		    child.add(sj1.get(j), sj1.getParams(j));		    child.add(sj2.get(j), sj2.getParams(j));		    // eliminate pipe's if applicable		    for (int k=0; k<2; k++) {			if (child.get(k) instanceof SIRPipeline) {			    Lifter.eliminatePipe((SIRPipeline)child.get(k));			}		    }		    sj3.add(child);		}		// replace sj1 and sj2 with sj3		pipe.remove(sj1);		pipe.remove(sj2);		pipe.add(i, sj3);		// subtract one from i since we shrunk the size of the		// pipe and need to reconsider this position above		i--;	    }	}	return madeChange;    }