fabs comes from libc, not libm, for historical reasons. Add a trivial C implementation for arm64.
Details
Details
Diff Detail
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
We could use inline asm with the fabs instruction, but the compiler generates reasonable code:
0000000000000000 <fabs>: 0: 1e602008 fcmp d0, #0.0 4: 54000045 b.pl c <fabs+0xc> 8: 1e614000 fneg d0, d0 c: d65f03c0 ret
lib/libc/aarch64/gen/fabs.c | ||
---|---|---|
33 ↗ | (On Diff #5359) | There should be a black newline for style (but I don't agree with that part of style(9), and should x be compared with 0. (with a .) to make it a floating-point value. |
Comment Actions
interesting, with Clang 3.7 I get:
fabs: 0: 01 40 61 1e fneg d1, d0 4: 08 20 60 1e fcmp d0, #0.0 8: 20 4c 60 1e fcsel d0, d1, d0, mi c: c0 03 5f d6 ret
lib/libc/aarch64/gen/fabs.S | ||
---|---|---|
31 ↗ | (On Diff #5368) | You also need a ret instruction. |