Skip to content

aarch64: incorrect emulation of sqshrn instruction

Host environment

  • Operating system: Debian
  • OS/kernel version: 6.5.13
  • Architecture: x86_64
  • QEMU flavor: qemu-aarch64
  • QEMU version: qemu-aarch64 version 8.1.2 (Debian 1:8.1.2+ds-1)
  • QEMU command line:
    $ qemu-aarch64 inline_asm_tests_arm64 --gtest_filter=Arm64InsnTest.SignedSaturatingShiftRightNarrowInt16x1

Emulated/Virtualized environment

  • Operating system: same as host
  • OS/kernel version: same as host
  • Architecture: aarch64

Description of problem

sqshrn instruction test fails with qemu-aarch64, but passes on real aarch64 hardware.

Steps to reproduce

  1. Build inline_asm_tests and run with qemu-aarch64
  2. Observe two failures
[ RUN      ] Arm64InsnTest.SignedSaturatingShiftRightNarrowInt16x1
frameworks/libs/binary_translation/tests/inline_asm_tests/main_arm64.cc:6697: Failure
Expected equality of these values:
  res1
    Which is: 4294967188
  MakeUInt128(0x94U, 0U)
    Which is: 148
[  FAILED  ] Arm64InsnTest.SignedSaturatingShiftRightNarrowInt16x1 (5 ms)
[ RUN      ] Arm64InsnTest.SignedSaturatingRoundingShiftRightNarrowInt16x1
frameworks/libs/binary_translation/tests/inline_asm_tests/main_arm64.cc:6793: Failure
Expected equality of these values:
  res3
    Which is: 4294967168
  MakeUInt128(0x0000000000000080ULL, 0x0000000000000000ULL)
    Which is: 128
[  FAILED  ] Arm64InsnTest.SignedSaturatingRoundingShiftRightNarrowInt16x1 (2 ms)

Additional information

Direct link to SignedSaturatingShiftRightNarrowInt16x1 test source

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information