diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-11-27 21:58:27 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-01-02 16:53:19 +0000 |
commit | 4ca1a2b7ad2ae5051d3cfa81e2985260f844213f (patch) | |
tree | 7d1ab434671925d557195e0f4b11ed5b2bfe4289 /src/qml/jit/qv4assembler.cpp | |
parent | 6cc333db9f96b96b8721a0112841595a3ff88917 (diff) |
Optimize ushr with constant argument
Change-Id: I891509269fc8e35c4ad45a2cdce03fc2ace574cd
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jit/qv4assembler.cpp')
-rw-r--r-- | src/qml/jit/qv4assembler.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/qml/jit/qv4assembler.cpp b/src/qml/jit/qv4assembler.cpp index 9583f6513e..e15cf32214 100644 --- a/src/qml/jit/qv4assembler.cpp +++ b/src/qml/jit/qv4assembler.cpp @@ -1641,27 +1641,32 @@ void Assembler::ushrConst(int rhs) { rhs &= 0x1f; pasm()->toInt32(); - if (rhs) // shift with 0 can act weird + if (rhs) { + // a non zero shift will always give a number encodable as an int pasm()->urshift32(TrustedImm32(rhs), PlatformAssembler::AccumulatorRegisterValue); - auto doubleEncode = pasm()->branch32(PlatformAssembler::LessThan, - PlatformAssembler::AccumulatorRegisterValue, - TrustedImm32(0)); - pasm()->setAccumulatorTag(IntegerTag); - auto done = pasm()->jump(); + pasm()->setAccumulatorTag(IntegerTag); + } else { + // shift with 0 can lead to a negative result + auto doubleEncode = pasm()->branch32(PlatformAssembler::LessThan, + PlatformAssembler::AccumulatorRegisterValue, + TrustedImm32(0)); + pasm()->setAccumulatorTag(IntegerTag); + auto done = pasm()->jump(); - doubleEncode.link(pasm()); - pasm()->convertUInt32ToDouble(PlatformAssembler::AccumulatorRegisterValue, - PlatformAssembler::FPScratchRegister, - PlatformAssembler::ScratchRegister); - pasm()->encodeDoubleIntoAccumulator(PlatformAssembler::FPScratchRegister); - done.link(pasm()); + doubleEncode.link(pasm()); + pasm()->convertUInt32ToDouble(PlatformAssembler::AccumulatorRegisterValue, + PlatformAssembler::FPScratchRegister, + PlatformAssembler::ScratchRegister); + pasm()->encodeDoubleIntoAccumulator(PlatformAssembler::FPScratchRegister); + done.link(pasm()); + } } void Assembler::shrConst(int rhs) { rhs &= 0x1f; pasm()->toInt32(); - if (rhs) // shift with 0 can act weird + if (rhs) pasm()->rshift32(TrustedImm32(rhs), PlatformAssembler::AccumulatorRegisterValue); pasm()->setAccumulatorTag(IntegerTag); } @@ -1670,7 +1675,7 @@ void Assembler::shlConst(int rhs) { rhs &= 0x1f; pasm()->toInt32(); - if (rhs) // shift with 0 can act weird + if (rhs) pasm()->lshift32(TrustedImm32(rhs), PlatformAssembler::AccumulatorRegisterValue); pasm()->setAccumulatorTag(IntegerTag); } |