# HG changeset patch # User Stefan Anzinger # Date 1406815658 25200 # Node ID 62f295bdea36b767c406ddf6e09a7d700b98769d # Parent 4ccd6b6b67808cf6679ce6bee6df4f6f902acf42 [SPARC] Fixing compare of short/char with constants, using half of single float registers as of now, otherwise it would overlap with double registers diff -r 4ccd6b6b6780 -r 62f295bdea36 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Wed Jul 30 14:49:41 2014 -0700 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Thu Jul 31 07:07:38 2014 -0700 @@ -221,7 +221,7 @@ @Override public void emitCompareBranch(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef trueDestination, LabelRef falseDestination, double trueDestinationProbability) { - boolean mirrored = emitCompare(left, right); + boolean mirrored = emitCompare(cmpKind, left, right); Condition finalCondition = mirrored ? cond.mirror() : cond; Kind kind = left.getKind().getStackKind(); switch (kind) { @@ -262,7 +262,7 @@ @Override public Variable emitConditionalMove(PlatformKind cmpKind, Value left, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue) { - boolean mirrored = emitCompare(left, right); + boolean mirrored = emitCompare(cmpKind, left, right); Condition finalCondition = mirrored ? cond.mirror() : cond; Variable result = newVariable(trueValue.getLIRKind()); @@ -287,11 +287,12 @@ * This method emits the compare instruction, and may reorder the operands. It returns true if * it did so. * + * @param cmpKind Kind how a and b have to be compared * @param a the left operand of the comparison * @param b the right operand of the comparison * @return true if the left and right operands were switched, false otherwise */ - protected boolean emitCompare(Value a, Value b) { + protected boolean emitCompare(PlatformKind cmpKind, Value a, Value b) { Variable left; Value right; boolean mirrored; @@ -304,7 +305,14 @@ right = loadNonConst(b); mirrored = false; } - switch (left.getKind().getStackKind()) { + switch ((Kind) cmpKind) { + case Short: + case Char: + append(new CompareOp(ICMP, emitZeroExtend(left, 16, 32), emitZeroExtend(right, 16, 32))); + break; + case Byte: + append(new CompareOp(ICMP, emitZeroExtend(left, 8, 32), emitZeroExtend(right, 8, 32))); + break; case Int: append(new CompareOp(ICMP, left, right)); break; @@ -906,14 +914,16 @@ } else { assert inputVal.getKind() == Kind.Int || inputVal.getKind() == Kind.Short || inputVal.getKind() == Kind.Byte : inputVal.getKind(); Variable result = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int)); - int mask = (int) IntegerStamp.defaultMask(fromBits); - Constant constant = Constant.forInt(mask); + long mask = IntegerStamp.defaultMask(fromBits); + Constant constant = Constant.forLong(mask); if (canInlineConstant(constant)) { append(new BinaryRegConst(SPARCArithmetic.IAND, result, asAllocatable(inputVal), constant, null)); + } else if (fromBits == 32) { + append(new ShiftOp(IUSHR, result, inputVal, Constant.forInt(0))); } else { Variable maskVar = newVariable(LIRKind.derive(inputVal).changeType(Kind.Int)); emitMove(maskVar, constant); - append(new BinaryRegReg(IAND, result, maskVar, (inputVal))); + append(new BinaryRegReg(IAND, result, maskVar, asAllocatable(inputVal))); } if (toBits > 32) { Variable longResult = newVariable(LIRKind.derive(inputVal).changeType(Kind.Long)); diff -r 4ccd6b6b6780 -r 62f295bdea36 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Wed Jul 30 14:49:41 2014 -0700 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Thu Jul 31 07:07:38 2014 -0700 @@ -59,7 +59,8 @@ for (Register reg : getAllocatableRegisters()) { if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { // Special treatment for double precision - if (kind == Kind.Double) { + // TODO: This is wasteful it uses only half of the registers as float. + if (kind == Kind.Double || kind == Kind.Float) { // Only even register numbers are valid double precision regs if (reg.number % 2 == 0) { list.add(reg);