0Day Forums
Hardware square root gcc - Printable Version

+- 0Day Forums (https://0day.red)
+-- Forum: Coding (https://0day.red/Forum-Coding)
+--- Forum: Assembly (https://0day.red/Forum-Assembly)
+--- Thread: Hardware square root gcc (/Thread-Hardware-square-root-gcc)



Hardware square root gcc - philliepgmkygi - 07-24-2023

I'm trying to use the hardware instructions to compute some mathematical functions. For example the square root (sqrtpd instruction). I'm compiling my C code with GCC.

Does Anybody know what are the gcc options to force to compile with the hardware instructions and not to use the libc? Or if I need to do something special on my source code? (Without writing asm code).


RE: Hardware square root gcc - chamois256 - 07-24-2023

On gcc you should use `__builtin_ia32_sqrtpd`.


RE: Hardware square root gcc - strewn699342 - 07-24-2023

The easiest way is to use optimization flags. -O1 generates

`sqrtsd %xmm1, %xmm0`

in assembly code. Try using -S flag with gcc to generate assembly and look how optimization flags works.


RE: Hardware square root gcc - silsby383 - 07-24-2023

Why don't you just write the desired hardware instruction in assembly code directly.

As far as I know, writing assembly code directly in c code is possible. It is called Inline Assembly. [ See here:

[To see links please register here]

]