Sign in Join

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

Mailing lists / fpc-pascal / 2003-01

adding zero

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Mark Emerson

In certain cases I find it useful for documenting my code to show "+0" when indexing an array...e.g.

x := a [m*n + 0];

Is the compiler smart enough to ignore my "+0"? .... or do I incur a slight performance penalty for including it?

Mark

Reply by email

Marco van de Voort
to Mark Emerson
Show quoted text 7 lines
In certain cases I find it useful for documenting my code to show "+0" when indexing an array...e.g. x := a [m*n + 0]; Is the compiler smart enough to ignore my "+0"? .... or do I incur a slight performance penalty for including it?

Only with register optimizations turned on (note that these are IIRC unstable in the 1.1 development version)

Reply by email

Peter Vreman
to Mark Emerson: In certain cases I find it useful for documenting my code to show "+0" when indexing an…
Show quoted text 7 lines
In certain cases I find it useful for documenting my code to show "+0" when indexing an array...e.g. x := a [m*n + 0]; Is the compiler smart enough to ignore my "+0"? .... or do I incur a slight performance penalty for including it?

The compiler does not remove the +0.

Btw. You can test it yourself by using the -al switch. It'll give you the assembler output and includes also the corresponding source lines.

Reply by email

Mark Emerson
to Peter Vreman
Peter Vreman wrote
The compiler does not remove the +0. Btw. You can test it yourself by using the -al switch. It'll give you the assembler output and includes also the corresponding source lines.

Thanks...but no thanks...I'll just do it this way:

x := a [m*n {+ 0}];

:)

Mark

Reply by email

Florian Klaempfl
to Mark Emerson
Mark Emerson wrote 12 lines
Peter Vreman wrote: >The compiler does not remove the +0. > >Btw. You can test it yourself by using the -al switch. It'll give you the >assembler output and includes also the corresponding source lines. Thanks...but no thanks...I'll just do it this way: x := a [m*n {+ 0}];

A pascal compiler shouldn't do any arithmetic transformations though in this case it should be done ;)

Reply by email