Test case for adcx and adox

前端 未结 2 1566
醉梦人生
醉梦人生 2021-01-22 03:22

I\'m testing Intel ADX add with carry and add with overflow to pipeline adds on large integers. I\'d like to see what expected code generation should look like. From _addcarry_u

2条回答
  •  失恋的感觉
    2021-01-22 03:47

    This does look like a good test-case. It assembles to correct working code, right? It's useful for a compiler to support the intrinsic in that sense, even if it doesn't yet support making optimal code. It lets people start using the intrinsic. This is necessary for compatibility.

    Next year or whenever the compiler's backend support for adcx/adox is done, the same code will compile to faster binaries with no source modification.

    I assume that's what's going on for gcc.


    clang 3.8.1's implementation is more literal, but it ends up doing a terrible job: flag-saving with sahf and push/pop of eax. See it on Godbolt.

    I think there's even a bug in the asm source output, since mov eax, ch won't assemble. (Unlike gcc, clang/LLVM uses a built-in assembler and doesn't actually go through a text representation of asm on the way from LLVM IR to machine code). The disassembly of the machine code shows mov eax,ebp there. I think that's also a bug, because bpl (or the rest of the register) doesn't have a useful value at that point. Probably it wanted mov al, ch or movzx eax, ch.

提交回复
热议问题