Elektrine lite

← Feed

@viduq@mstdn.social

Post #2639686

2025-05-15 14:38 UTC

@ela@infosec.exchange how can the compiler break down a recursive function to a mathematical statement? There is no brute force involved or is there? And does it do that only when optimizations are on?

Replies (3)

  • @ela@infosec.exchange 2025-05-15 14:56

    @viduq@mstdn.social It's not exactly brute force, but it does involve some heavy lifting in the optimizer. Tail recursion elimination turns the recursive calls into a loop. Then, induction variables of the loop are detected, and finally strength reduction, algebraic simplification finish it off.

    Open ##2639687

  • @dpiponi@mathstodon.xyz 2025-05-15 21:12

    @viduq@mstdn.social @ela@infosec.exchange Check out how examples like this are also reduced to simple polynomials without loops: https://godbolt.org/z/cze5Y1b7j The -1431655764 is pretty fiendish if you've not met that trick before.

    Open ##2639693

  • @jaj@mastodon.social 2025-05-15 21:51

    @viduq@mstdn.social It uses an LLM to explain the code (no I'm joking, we're not there yet) @ela@infosec.exchange

    Open ##2639694