# HG changeset patch # User Doug Simon # Date 1386940230 -3600 # Node ID ac5243877cc7e60e8761323d553707af2b38a8e8 # Parent da085171251983ec2952de0edd070451563cdf56 made commoning of loading constants non-configurable (GRAAL-508) diff -r da0851712519 -r ac5243877cc7 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Fri Dec 13 14:05:48 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Fri Dec 13 14:10:30 2013 +0100 @@ -83,12 +83,6 @@ private final boolean printIRWithLIR; /** - * Maps constants to variables within the scope of a single block to avoid loading a constant - * more than once per block. - */ - private Map constantsLoadedInCurrentBlock; - - /** * Handle for an operation that loads a constant into a variable. The operation starts in the * first block where the constant is used but will eventually be * {@linkplain LIRGenerator#insertConstantLoads() moved} to a block dominating all usages of the @@ -240,12 +234,6 @@ return operand; } - /** - * Controls whether commoning is performed on {@linkplain #canInlineConstant(Constant) - * non-inlinable} constants. - */ - private static final boolean CommonConstantLoads = Boolean.parseBoolean(System.getProperty("graal.commonConstantLoads", "true")); - private Value getConstantOperand(ValueNode node) { if (!ConstantNodeRecordsUsages) { Constant value = node.asConstant(); @@ -254,42 +242,29 @@ return !node.isExternal() ? setResult(node, value) : value; } else { Variable loadedValue; - if (CommonConstantLoads) { - if (constantLoads == null) { - constantLoads = new HashMap<>(); - } - LoadConstant load = constantLoads.get(value); - if (load == null) { - int index = lir.lir(currentBlock).size(); - // loadedValue = newVariable(value.getPlatformKind()); - loadedValue = emitMove(value); - LIRInstruction op = lir.lir(currentBlock).get(index); - constantLoads.put(value, new LoadConstant(loadedValue, currentBlock, index, op)); + if (constantLoads == null) { + constantLoads = new HashMap<>(); + } + LoadConstant load = constantLoads.get(value); + if (load == null) { + int index = lir.lir(currentBlock).size(); + // loadedValue = newVariable(value.getPlatformKind()); + loadedValue = emitMove(value); + LIRInstruction op = lir.lir(currentBlock).get(index); + constantLoads.put(value, new LoadConstant(loadedValue, currentBlock, index, op)); + } else { + Block dominator = ControlFlowGraph.commonDominator(load.block, currentBlock); + loadedValue = load.variable; + if (dominator != load.block) { + if (load.index >= 0) { + List instructions = lir.lir(load.block); + instructions.set(load.index, new NoOp(null, -1)); + load.index = -1; + } } else { - Block dominator = ControlFlowGraph.commonDominator(load.block, currentBlock); - loadedValue = load.variable; - if (dominator != load.block) { - if (load.index >= 0) { - List instructions = lir.lir(load.block); - instructions.set(load.index, new NoOp(null, -1)); - load.index = -1; - } - } else { - assert load.block != currentBlock || load.index < lir.lir(currentBlock).size(); - } - load.block = dominator; + assert load.block != currentBlock || load.index < lir.lir(currentBlock).size(); } - } else { - if (constantsLoadedInCurrentBlock == null) { - constantsLoadedInCurrentBlock = new HashMap<>(); - loadedValue = null; - } else { - loadedValue = constantsLoadedInCurrentBlock.get(value); - } - if (loadedValue == null) { - loadedValue = emitMove(value); - constantsLoadedInCurrentBlock.put(value, loadedValue); - } + load.block = dominator; } return loadedValue; } @@ -442,7 +417,6 @@ } currentBlock = block; - resetLoadedConstants(); // set up the list of LIR instructions assert lir.lir(block) == null : "LIR list already computed for this block"; @@ -506,12 +480,6 @@ } } - private void resetLoadedConstants() { - if (constantsLoadedInCurrentBlock != null && !constantsLoadedInCurrentBlock.isEmpty()) { - constantsLoadedInCurrentBlock.clear(); - } - } - protected abstract boolean peephole(ValueNode valueNode); private boolean hasBlockEnd(Block block) {