private static void raiseVectorConstants (SIRFilter filter) {
private static void raiseVectorConstants (final SIRFilter filter) {
    private static void raiseVectorConstants (SIRFilter filter) {                // Find all JVectorLiteral's in all methods, record in vlitToMeths        // (Map needs to convert to Number which has structural equality / hash        // from JVectorLiteral which has identity equality / hash.)        final Map<Number,Set<JMethodDeclaration>>vlitToMeths =             new HashMap<Number,Set<JMethodDeclaration>>();        JMethodDeclaration[] ms = filter.getMethods();        for (final JMethodDeclaration m : ms) {            m.accept(new SLIREmptyVisitor(){                @Override                public void visitVectorLiteral(JVectorLiteral self, JLiteral scalar) {                    Set<JMethodDeclaration> inMs = vlitToMeths.get(self);                    if (inMs == null) inMs = new HashSet<JMethodDeclaration>();                    inMs.add(m);                    JLiteral scalarv = self.getScalar();                    Number n;                    if (scalarv instanceof JIntLiteral) {                        n = ((JIntLiteral)scalarv).intValue();                    } else if (scalarv instanceof JFloatLiteral) {                        n = ((JFloatLiteral)scalarv).floatValue();                    } else {                        throw new AssertionError();                    }                    vlitToMeths.put(n, inMs);                }            });        }                // create const definitions for the JVectorLiteral's and record references in vlitReplacements        final Map<Number,JExpression> vlitReplacements =  new HashMap<Number,JExpression>();        for (Map.Entry<Number,Set<JMethodDeclaration>> vMeths : vlitToMeths.entrySet()) {            Number vnum = vMeths.getKey();            JLiteral scalar;            CNumericType scalartype;            if (vnum instanceof Integer) {                scalartype = CStdType.Integer;                scalar = new JIntLiteral((Integer)vnum);            } else if (vnum instanceof Float) {                scalartype = CStdType.Float;                scalar = new JFloatLiteral((Float)vnum);            } else {                throw new AssertionError();            }            JExpression[] initElems = new JExpression[KjcOptions.vectorize / 4];            for (int i = 0; i < initElems.length; i++) {                initElems[i] = (JExpression)AutoCloner.deepCopy(scalar);            }            JArrayInitializer init = new JArrayInitializer(initElems);            JVariableDefinition defn = new JVariableDefinition(                    at.dms.kjc.Constants.ACC_STATIC | at.dms.kjc.Constants.ACC_FINAL,                    new CVectorTypeLow(scalartype, KjcOptions.vectorize),                    ThreeAddressCode.nextTemp(),                     init);            if (vMeths.getValue().size() > 1) {                // constant used in multiple methods: set up as field.                JFieldDeclaration decl = new JFieldDeclaration(defn);                JFieldAccessExpression access = new JFieldAccessExpression(new JThisExpression(), defn.getIdent());                filter.addField(0,decl);                vlitReplacements.put(vnum, access);            } else {                // constant used in single method: set up as local.                JVariableDeclarationStatement decl = new JVariableDeclarationStatement(defn);                JLocalVariableExpression access = new JLocalVariableExpression(defn);                for (JMethodDeclaration m : vMeths.getValue()) {                    // this loop should iterate exactly once                    m.getBody().addStatement(0, decl);                }                vlitReplacements.put(vnum, access);            }        }        // replace references to vector constants with references to variable.        for (final JMethodDeclaration m : ms) {            m.accept(new SLIRReplacingVisitor(){                @Override                public Object visitVectorLiteral(JVectorLiteral self, JLiteral scalar) {                    Number n;                    JLiteral l = self.getScalar();                    if (l instanceof JIntLiteral) {                        n = ((JIntLiteral)l).intValue();                    } else if (l instanceof JFloatLiteral) {                        n = ((JFloatLiteral)l).floatValue();                    } else {                        throw new AssertionError();                    }                    return vlitReplacements.get(n);                }            });        }    }