Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: I found a F...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 35 of 53 Topic 3681 of 4325
Post > Topic >>

Re: I found a FORTH stack optimzer, but could use a better version.

by foxchip <fox@[EMAIL PROTECTED] > Jan 6, 2008 at 01:26 PM

On Jan 6, 9:34 am, Bernd Paysan <bernd.pay...@[EMAIL PROTECTED]
> wrote:
> foxchip wrote:
> > Simple peephole optimizers are often used
> > to patch badly generated code this way.
>
> The quite simple peephole optimizer I've implemented in bigFORTH nearly
20
> years ago wasn't there to improve badly code; most patterns I've put in
> were there to improve good code.

I suppose I was being too black/white.  Chuck once asked how it should
be phrased, "Optimized/not optimized?"  "Optimal/non-optimal?"
In any event he asked, "Is it your goal to write non-optimal code?"

When you write optimized code a peephole optimizer is useless. It can
only improve non-optimal code.  Maybe not the worst code ever, and
maybe
you call it 'good' code.  I was simply saying that optimized code
cannot be optimized by something like a peephole optimizer.

A simple code optimizer that does macro-inclining in a brain-dead way
will not generate optimimal code, and it is the sort of things I
called the 'bad' code that a cheap peephole optimizer can improve.

> But it is a peephole optimizer on the machine code level
> (68k and later x86 machine code). The intention was to
> be simple (the rule interpreter is two screens, the rules themselves
take a
> line each), fast and reversible. SEE can undo most of the optimizations
to
> figure out what kind of source code might have generated the machine
code.

That's a bit more sophisticated than a simple peephole optimizer that
attempts to combine code segments at the Forth primitive level.  You
are
talking about native code optimization in environments with more
details
there.  In that context I understand your comment that the technique
can
'optimize' the native code generated by a native code compiler.

That's not quite the same thing as wanting to optimize "SWAP +"
which is what I was talking about.  You are getting away from the
idea that optimizers are good for the "OVER DROP DUP DROP SWAP + DROP"
problem and come back to the issue of what one has to do to translate
between what is efficient on a processor designed to run some kind of
code and code expressed in some language.

> Today, a real native code compiler can be a factor 1.5-2 faster for good
> code, and a factor 5-10 for bad code.

That is exactly the sort of thing that I was addressing.  You are
using
the phrase 'real native code' in a way that assumes that it means C
style hardware and software.  Worse yet is assumes that what it is
comparing too is so universally understood that it does not even need
to be stated explicitly.

You don't even state 'what' a 'real native code compiler' is being
compared to.  It is easy to say 'it is ten times faster' if you don't
give what you compare to because you can always produce something
ten times as lame as the example claimed to be ten times better.

After a decade of arguing with Chuck about this I concluded a decade
ago that he had been right in the first place. It was more productive
to write the optimized code in the first place because the best
optimizing compilers could not achieve even a 1 to 1 let alone a
10 to 1 compared to that.

> I've started a real native code
> compiler for my 4stack processor (quite different target), and I'm
planning
> to implement one with similar algorithms for x86_64, where the
additional
> registers increase the benefit vs. the peephole optimizer. As time
permits,
> for sure.

I have written 'real native code' compilers for stack processors.
Other
people were happy with simple compilers but I wanted to see whether
having
hundreds of native code sequences and dozens of rules for code
optimization.
After lots of work, lots of experience, and lots of observing master
Forth
programmers in action I concluded that it was better for some people
to
have the intention to write optimized code in the first place.

I understand that this is not popular and as Chuck has said is
responsible
for Forth having a reputation as an elitist language.  The real value
of
code optimizers is for the intention to write bad code in the first
place.

Best Wishes
 




 53 Posts in Topic:
I found a FORTH stack optimzer, but could use a better version.
"Rod Pemberton"  2008-01-06 00:26:01 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 09:22:17 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 04:37:47 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 11:00:53 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 06:10:48 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 06:24:17 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 12:58:34 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:27:20 
Re: I found a FORTH stack optimzer, but could use a better versi
Coos Haak <chforth@[EM  2008-01-06 21:16:07 
Re: I found a FORTH stack optimzer, but could use a better versi
"Ed" <nospam  2008-01-07 17:51:08 
Re: I found a FORTH stack optimzer, but could use a better versi
Albert van der Horst <  2008-01-07 17:22:03 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 13:00:32 
Re: I found a FORTH stack optimzer, but could use a better versi
none <""jan\  2008-01-06 14:07:31 
Re: I found a FORTH stack optimzer, but could use a better versi
mhx@[EMAIL PROTECTED] (M  2008-01-06 15:27:04 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:32:53 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:05:30 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-06 13:42:55 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 06:09:25 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-06 13:46:06 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 18:25:08 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-07 10:58:44 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-07 21:39:25 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-07 22:57:58 
Re: I found a FORTH stack optimzer, but could use a better versi
Albert van der Horst <  2008-01-08 08:13:03 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-08 05:07:03 
Re: I found a FORTH stack optimzer, but could use a better versi
Albert van der Horst <  2008-01-08 18:26:32 
Re: I found a FORTH stack optimzer, but could use a better versi
Alex McDonald <blog@[E  2008-01-08 03:04:52 
Re: I found a FORTH stack optimzer, but could use a better versi
Roelf Toxopeus <these3  2008-01-06 15:24:29 
Re: I found a FORTH stack optimzer, but could use a better
winston19842005 <bjjly  2008-01-06 10:13:11 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:01:26 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:52:02 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 08:54:01 
Re: I found a FORTH stack optimzer, but could use a better versi
Bernd Paysan <bernd.pa  2008-01-06 18:34:43 
Re: I found a FORTH stack optimzer, but could use a better versi
helmwo@[EMAIL PROTECTED]   2008-01-06 10:27:48 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 13:26:05 
Re: I found a FORTH stack optimzer, but could use a better versi
Bernd Paysan <bernd.pa  2008-01-06 23:02:25 
Re: I found a FORTH stack optimzer, but could use a better versi
kenney@[EMAIL PROTECTED]   2008-01-07 09:47:13 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-06 13:43:00 
Re: I found a FORTH stack optimzer, but could use a better versi
Jenny Brien <jennybrie  2008-01-08 14:06:38 
Re: I found a FORTH stack optimzer, but could use a better versi
Bill <bill@[EMAIL PROT  2008-01-08 21:20:47 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-09 04:57:34 
Re: I found a FORTH stack optimzer, but could use a better versi
Jenny Brien <jennybrie  2008-01-10 09:50:29 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-11 03:34:02 
Re: I found a FORTH stack optimzer, but could use a better versi
"Jenny Brien" &  2008-01-11 17:49:07 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-12 04:31:21 
Re: I found a FORTH stack optimzer, but could use a better versi
astrobe <fdubois76@[EM  2008-01-14 09:31:33 
Re: I found a FORTH stack optimzer, but could use a better versi
foxchip <fox@[EMAIL PR  2008-01-19 10:11:10 
Re: I found a FORTH stack optimzer, but could use a better versi
stephenXXX@[EMAIL PROTECT  2008-01-20 15:33:32 
Re: I found a FORTH stack optimzer, but could use a better versi
ygrek <ygrek@[EMAIL PR  2008-01-06 12:31:47 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 17:58:45 
Re: I found a FORTH stack optimzer, but could use a better versi
anton@[EMAIL PROTECTED]   2008-01-06 18:22:00 
Re: I found a FORTH stack optimzer, but could use a better versi
"Rod Pemberton"  2008-01-06 18:18:56 
Re: I found a FORTH stack optimzer, but could use a better versi
ygrek <ygrek@[EMAIL PR  2008-01-07 09:05:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 14:53:03 CST 2008.