[LLVMdev] [x86 codegen] 3DNow! intrinsics not behaving as expected.

Eli Friedman eli.friedman at gmail.com
Thu Apr 14 12:47:30 PDT 2011


On Thu, Apr 14, 2011 at 12:16 PM, Michael Spencer <bigcheesegs at gmail.com> wrote:
> I finally got all of the 3DNow! instruction intrinsics and builtins
> into LLVM and Clang, however, while testing them, I've noticed that
> they produce incorrect results.
>
> For example:
>
> typedef float V2f __attribute__((vector_size(8)));
>
> int main() {
>  V2f dest, a = {1.0, 3.0}, b = {10.0, 3.5};
>  dest = __builtin_ia32_pfadd(a, b);
>  printf("(%f, %f)\n", dest[0], dest[1]);
> }
>
> Should output (11, 6.5). However, it outputs different values
> depending on the optimization level. Generally one of them is correct,
> and the other is -nan.
>
> I looked at the program using a debugger, and the pfadd instruction is
> executed correctly and the MMX register contains the correct values.
> The code that prepares the stack for the printf call seems to be
> messing it up.

I would call that "user error"; basically, using MMX instructions
messes up the FP stack, and we assume the user is smart enough to make
sure the two don't mix.

-Eli




More information about the llvm-dev mailing list