Mercurial > hg > graal-compiler
changeset 23185:8e0474380822
[SPARC] Fix overflow detection in 32 bit multiply
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Tue, 15 Dec 2015 17:20:29 +0100 |
parents | ad619505dbd1 |
children | c37db3aa7e43 |
files | graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Mon Dec 14 13:15:59 2015 -0800 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Tue Dec 15 17:20:29 2015 +0100 @@ -233,11 +233,15 @@ protected void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { try (ScratchRegister tmpScratch = masm.getScratchRegister()) { Register tmp = tmpScratch.getRegister(); - masm.mulx(asRegister(x, WORD), asRegister(y, WORD), asRegister(result, WORD)); + Register resultRegister = asRegister(result, WORD); + Register xRegister = asRegister(x, WORD); + Register yRegister = asRegister(y, WORD); + masm.sra(xRegister, 0, xRegister); + masm.sra(yRegister, 0, yRegister); + masm.mulx(xRegister, yRegister, resultRegister); Label noOverflow = new Label(); - masm.sra(asRegister(result, WORD), 0, tmp); - masm.xorcc(SPARC.g0, SPARC.g0, SPARC.g0); - masm.compareBranch(tmp, asRegister(result), Equal, Xcc, noOverflow, PREDICT_TAKEN, null); + masm.sra(resultRegister, 0, tmp); + masm.compareBranch(tmp, resultRegister, Equal, Xcc, noOverflow, PREDICT_TAKEN, null); masm.wrccr(SPARC.g0, 1 << (SPARCAssembler.CCR_ICC_SHIFT + SPARCAssembler.CCR_V_SHIFT)); masm.bind(noOverflow); }