Elektrine lite

← Feed

@saagar@federated.saagarjha.com

Post #2598506

2023-03-19 09:46 UTC

@slomo@toot.cat Consider, for example: int foo(int i) { if (!i) { exit(0); } else { return do_expensive_thing(i); } } void bar(int a, int b) { return a + b; } How you generate code for bar(foo(/* something */), foo(/* another thing */)) can change.

Replies (1)

  • @slomo@toot.cat If we can change evaluation order, a smart compiler may decide to inline and reorder so the code to look like this: if (!/* something */ || !/* another thing */) { exit(0); } else { foo(/* something */) + foo(/* another thing */) }

    Open ##2598507