Skip to content

ppc64: VSX vector float to integer conversion instructions do not always return expected results on QEMU 8.0.4 if source vector has NaN values

Host environment

  • Operating system: Ubuntu 22.04
  • OS/kernel version: Linux ip-10-0-1-10 6.2.0-1012-aws #12~22.04.1-Ubuntu SMP Thu Sep 7 14:01:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • Architecture: x86_64
  • QEMU flavor: qemu-ppc64le
  • QEMU version: 8.0.4
  • QEMU command line: qemu-ppc64le -L /usr/powerpc64le-linux-gnu ./vsx_f2i_nan_test_program_101423

Emulated/Virtualized environment

  • Operating system: Ubuntu 22.04
  • OS/kernel version: Linux ip-10-0-1-10 6.2.0-1012-aws #12~22.04.1-Ubuntu SMP Thu Sep 7 14:01:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • Architecture: ppc64le

Description of problem

The problem is that the VSX xvcvspsxws/xvcvdpsxws/xvcvspsxds/xvcvdpsxds/xvcvspuxws/xvcvdpuxds/xvcvspuxds/xvcvdpuxws instructions incorrectly convert the preceding non-NaN source values to the NaN to integer result instead of the expected non-NaN to integer conversion result with qemu-ppc64le 8.0.4.

Here are the results of the VSX operations whose results differ from the expected results with QEMU 8.0.4 (generated by running the vsx_f2i_nan_test_program_101423 test program with qemu-ppc64le 8.0.4):

xvcvspsxds ({1, 2, 3, nan}) = {-9223372036854775808, -9223372036854775808}
xvcvspsxds ({nan, 2, 3, nan}) = {-9223372036854775808, -9223372036854775808}
xvcvspsxds ({1, 2, nan, nan}) = {-9223372036854775808, -9223372036854775808}
xvcvspsxds ({nan, 2, nan, nan}) = {-9223372036854775808, -9223372036854775808}

xvcvspsxws ({1, nan, 3, 4}) = {-2147483648, -2147483648, 3, 4}
xvcvspsxws ({1, 2, nan, 4}) = {-2147483648, -2147483648, -2147483648, 4}
xvcvspsxws ({nan, 2, nan, 4}) = {-2147483648, -2147483648, -2147483648, 4}
xvcvspsxws ({1, nan, nan, 4}) = {-2147483648, -2147483648, -2147483648, 4}
xvcvspsxws ({1, 2, 3, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}
xvcvspsxws ({nan, 2, 3, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}
xvcvspsxws ({1, nan, 3, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}
xvcvspsxws ({nan, nan, 3, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}
xvcvspsxws ({1, 2, nan, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}
xvcvspsxws ({nan, 2, nan, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}
xvcvspsxws ({1, nan, nan, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}

xvcvspuxds ({1, 2, 3, nan}) = {0, 0}
xvcvspuxds ({nan, 2, 3, nan}) = {0, 0}
xvcvspuxds ({1, 2, nan, nan}) = {0, 0}
xvcvspuxds ({nan, 2, nan, nan}) = {0, 0}

xvcvspuxws ({1, nan, 3, 4}) = {0, 0, 3, 4}
xvcvspuxws ({1, 2, nan, 4}) = {0, 0, 0, 4}
xvcvspuxws ({nan, 2, nan, 4}) = {0, 0, 0, 4}
xvcvspuxws ({1, nan, nan, 4}) = {0, 0, 0, 4}
xvcvspuxws ({1, 2, 3, nan}) = {0, 0, 0, 0}
xvcvspuxws ({nan, 2, 3, nan}) = {0, 0, 0, 0}
xvcvspuxws ({1, nan, 3, nan}) = {0, 0, 0, 0}
xvcvspuxws ({nan, nan, 3, nan}) = {0, 0, 0, 0}
xvcvspuxws ({1, 2, nan, nan}) = {0, 0, 0, 0}
xvcvspuxws ({nan, 2, nan, nan}) = {0, 0, 0, 0}
xvcvspuxws ({1, nan, nan, nan}) = {0, 0, 0, 0}

xvcvdpsxws ({1, nan}) = {-2147483648, -2147483648, -2147483648, -2147483648}

xvcvdpuxws ({1, nan}) = {0, 0, 0, 0}

xvcvdpsxds ({1, nan}) = {-9223372036854775808, -9223372036854775808}

xvcvdpuxds ({1, nan}) = {0, 0}

Here are the results of the same VSX conversion operations with QEMU 6.2.0 (generated by running the vsx_f2i_nan_test_program_101423 test program with qemu-ppc64le 6.2.0):

xvcvspsxds ({1, 2, 3, nan}) = {2, -9223372036854775808}
xvcvspsxds ({nan, 2, 3, nan}) = {2, -9223372036854775808}
xvcvspsxds ({1, 2, nan, nan}) = {2, -9223372036854775808}
xvcvspsxds ({nan, 2, nan, nan}) = {2, -9223372036854775808}

xvcvspsxws ({1, nan, 3, 4}) = {1, -2147483648, 3, 4}
xvcvspsxws ({1, 2, nan, 4}) = {1, 2, -2147483648, 4}
xvcvspsxws ({nan, 2, nan, 4}) = {-2147483648, 2, -2147483648, 4}
xvcvspsxws ({1, nan, nan, 4}) = {1, -2147483648, -2147483648, 4}
xvcvspsxws ({1, 2, 3, nan}) = {1, 2, 3, -2147483648}
xvcvspsxws ({nan, 2, 3, nan}) = {-2147483648, 2, 3, -2147483648}
xvcvspsxws ({1, nan, 3, nan}) = {1, -2147483648, 3, -2147483648}
xvcvspsxws ({nan, nan, 3, nan}) = {-2147483648, -2147483648, 3, -2147483648}
xvcvspsxws ({1, 2, nan, nan}) = {1, 2, -2147483648, -2147483648}
xvcvspsxws ({nan, 2, nan, nan}) = {-2147483648, 2, -2147483648, -2147483648}
xvcvspsxws ({1, nan, nan, nan}) = {1, -2147483648, -2147483648, -2147483648}

xvcvspuxds ({1, 2, 3, nan}) = {2, 0}
xvcvspuxds ({nan, 2, 3, nan}) = {2, 0}
xvcvspuxds ({1, 2, nan, nan}) = {2, 0}
xvcvspuxds ({nan, 2, nan, nan}) = {2, 0}

xvcvspuxws ({1, nan, 3, 4}) = {1, 0, 3, 4}
xvcvspuxws ({1, 2, nan, 4}) = {1, 2, 0, 4}
xvcvspuxws ({nan, 2, nan, 4}) = {0, 2, 0, 4}
xvcvspuxws ({1, nan, nan, 4}) = {1, 0, 0, 4}
xvcvspuxws ({1, 2, 3, nan}) = {1, 2, 3, 0}
xvcvspuxws ({nan, 2, 3, nan}) = {0, 2, 3, 0}
xvcvspuxws ({1, nan, 3, nan}) = {1, 0, 3, 0}
xvcvspuxws ({nan, nan, 3, nan}) = {0, 0, 3, 0}
xvcvspuxws ({1, 2, nan, nan}) = {1, 2, 0, 0}
xvcvspuxws ({nan, 2, nan, nan}) = {0, 2, 0, 0}
xvcvspuxws ({1, nan, nan, nan}) = {1, 0, 0, 0}

xvcvdpsxws ({1, nan}) = {0, 1, 0, -2147483648}

xvcvdpuxws ({1, nan}) = {0, 1, 0, 0}

xvcvdpsxds ({1, nan}) = {1, -9223372036854775808}

xvcvdpuxds ({1, nan}) = {1, 0}

Steps to reproduce

  1. Compile the attached vsx_f2i_nan_test_program_101423.cpp with either powerpc64le-linux-gnu-g++ or clang --target=powerpc64le-linux-gnu
  2. Run the compiled vsx_f2i_nan_test_program_101423.cpp program using qemu-ppc64le
  3. The vsx_f2i_nan_test_program_101423 program will return the results of the xvcvspsxws, xvcvdpsxws, xvcvspsxds, xvcvdpsxds, xvcvspuxws, xvcvdpuxds, xvcvspuxds, or xvcvdpuxws instruction.

Additional information

Attachments:

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