Mercurial > hg > truffle
changeset 15278:3ef4196cf8e5
use movl instead of andl for L2I
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Tue, 22 Apr 2014 17:25:31 -0700 |
parents | 87ce885d0b83 |
children | 041156bb59b2 |
files | graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java |
diffstat | 2 files changed, 28 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Tue Apr 22 17:25:27 2014 -0700 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Tue Apr 22 17:25:31 2014 -0700 @@ -53,6 +53,7 @@ import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary1Op; import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2MemoryOp; import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2Op; +import com.oracle.graal.lir.amd64.AMD64Arithmetic.Unary2RegOp; import com.oracle.graal.lir.amd64.AMD64Compare.CompareMemoryOp; import com.oracle.graal.lir.amd64.AMD64Compare.CompareOp; import com.oracle.graal.lir.amd64.AMD64ControlFlow.BranchOp; @@ -765,9 +766,9 @@ } } - private AllocatableValue emitConvert1Op(PlatformKind kind, AMD64Arithmetic op, AllocatableValue input) { + private AllocatableValue emitConvert2RegOp(PlatformKind kind, AMD64Arithmetic op, AllocatableValue input) { Variable result = newVariable(kind); - append(new Unary1Op(op, result, input)); + append(new Unary2RegOp(op, result, input)); return result; } @@ -850,7 +851,7 @@ public Value emitNarrow(Value inputVal, int bits) { if (inputVal.getKind() == Kind.Long && bits <= 32) { // TODO make it possible to reinterpret Long as Int in LIR without move - return emitConvert1Op(Kind.Int, L2I, asAllocatable(inputVal)); + return emitConvert2RegOp(Kind.Int, L2I, asAllocatable(inputVal)); } else { return inputVal; }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Tue Apr 22 17:25:27 2014 -0700 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Tue Apr 22 17:25:31 2014 -0700 @@ -82,6 +82,27 @@ } /** + * Unary operation with separate source and destination operand but register only. + */ + public static class Unary2RegOp extends AMD64LIRInstruction { + + @Opcode private final AMD64Arithmetic opcode; + @Def({REG}) protected AllocatableValue result; + @Use({REG}) protected AllocatableValue x; + + public Unary2RegOp(AMD64Arithmetic opcode, AllocatableValue result, AllocatableValue x) { + this.opcode = opcode; + this.result = result; + this.x = x; + } + + @Override + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); + } + } + + /** * Unary operation with single operand for source and destination. */ public static class Unary1Op extends AMD64LIRInstruction { @@ -431,9 +452,6 @@ case LNOT: masm.notq(asLongReg(result)); break; - case L2I: - masm.andl(asIntReg(result), 0xFFFFFFFF); - break; default: throw GraalInternalError.shouldNotReachHere(); } @@ -568,6 +586,9 @@ case I2L: masm.movslq(asLongReg(dst), asIntReg(src)); break; + case L2I: + masm.movl(asIntReg(dst), asLongReg(src)); + break; case F2D: masm.cvtss2sd(asDoubleReg(dst), asFloatReg(src)); break;