Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-10

Odd question?

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

mm

Hello,

Contrary to Delphi, FPC doesn't inline the "Odd()" functions. I agree this is not very important for most programs but this is annoying for 'math' programs. A few months ago, I re-started to work on my NX library and currently, just because FPC doesn't inline "Odd()", its code is stuffed with expressions like "if (N and 1) 0 then" (it works but this is less legible than "if Odd(N) then").

The inlined code shouldn't be much bigger than the calls to "Odd()". So, why aren't they inlined? Is there a reason you did so?

mm
http://www.ellipsa.net/

Reply by email

Jonas Maebe
to mm
mm wrote
The inlined code shouldn't be much bigger than the calls to "Odd ()". So, why aren't they inlined? Is there a reason you did so?

It's because the Odd function is an assembler function, and the compiler can't yet inline assembler functions. I guess this stems from the time that the compiler was not very good at inlining nor at removing stack frames. I would probably be best to simply remove all assembler implementations of Odd() from the rtl so the generic Pascal version is used instead (which can be inlined).

Jonas

Reply by email

Michael Schnell
to Jonas Maebe
Show quoted text 6 lines
It's because the Odd function is an assembler function, and the compiler can't yet inline assembler functions. I guess this stems from the time that the compiler was not very good at inlining nor at removing stack frames. I would probably be best to simply remove all assembler implementations of Odd() from the rtl so the generic Pascal version is used instead (which can be inlined).

Isn't Odd simply
(i and 1) 0

?

Reply by email

Jonas Maebe
to Michael Schnell
Michael Schnell wrote 8 lines
> It's because the Odd function is an assembler function, and the > compiler can't yet inline assembler functions. I guess this stems > from the time that the compiler was not very good at inlining nor > at removing stack frames. I would probably be best to simply > remove all assembler implementations of Odd() from the rtl so the > generic Pascal version is used instead (which can be inlined). Isn't Odd simply (i and 1) 0

Yes, that's the pretty much the content of the Pascal function.

Jonas

Reply by email

mm
to Jonas Maebe: It's because the Odd function is an assembler function, and the compiler can't yet inline…
Jonas Maebe wrote 12 lines
On 18 Oct 2007, at 16:17, mm wrote: > The inlined code shouldn't be much bigger than the calls to "Odd()". So, > why aren't they inlined? Is there a reason you did so? It's because the Odd function is an assembler function, and the compiler can't yet inline assembler functions. I guess this stems from the time that the compiler was not very good at inlining nor at removing stack frames. I would probably be best to simply remove all assembler implementations of Odd() from the rtl so the generic Pascal version is used instead (which can be inlined).

Ok, thanks. Thus it is quite possible (without too much work) to adapt FPC so that it inlines the Odd() functions. Should I ask for it on the Free Pascal bugtracker page?

mm
http://www.ellipsa.net/

Reply by email