Skip to content

Failure from pext on x86-64

test-primops generates the following program which fails with a floating-point exception on x86-64/Linux:

zext[W16→W64](0::W16 /u ((((zext[W8→W16](0x12::W8 + (load[W8](0x17dd4::W64)))) & 0x59f8::W16) << 0xa::W64) /s 0xffff::W16))

I'm not yet sure whether this is a test-primops issue or a GHC bug.

test.cmm

#include "Cmm.h"

test ( bits64 buffer ) {
  bits64 ret;
  (ret) = prim %pext64(
    %zx64(%divu(
      (0 :: bits16),
      %quot(
        %shl(
          (%zx16(((18 :: bits8) + bits8[buffer + (97748 :: bits64)])) & (23032 :: bits16)),
          (10 :: bits64)
        ),
        (-1 :: bits16))
    )),
    (0 :: bits64)
  );
  return (ret);
}
Edited by Ben Gamari