# HG changeset patch # User Tom Rodriguez # Date 1398212731 25200 # Node ID 3ef4196cf8e57250bbe7b5f0ece447934b7a2ddd # Parent 87ce885d0b8341e9ca9e14536c46a997e56c8123 use movl instead of andl for L2I diff -r 87ce885d0b83 -r 3ef4196cf8e5 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- 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; } diff -r 87ce885d0b83 -r 3ef4196cf8e5 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java --- 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;