Skip to content

Shrink the size of sine table #13

Closed
@jserv

Description

@jserv

In the file src/trig.c, there is a lookup table for the sine function pre-calculated with fixed-point arithmetic. According to the size command provided by binutils, the lookup table and its related functions (sin, cos, tan) contribute more than 2 KiB to the code size on Aarch64.

$ size .libtwin.a/src/trig.c.o
   text	   data	    bss	    dec	    hex	filename
   2460	      0	      0	   2460	    99c	.libtwin.a/src/trig.c.o

Instead of relying on table lookups, we can perform calculations on the fly and ensure a reasonably fast response time by utilizing a smaller table or a combination of bit operations. Additionally, instead of invoking twin_sin and twin_cos functions, we can use the sincos function to retrieve sine and cosine values simultaneously, reducing the number of function calls.

Reference: 2024 Report

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions