

|
 |
| Programming > Forth > Re: I found a F... |
|
| << Topic |
< Post |
Post 36 of 53 Topic 3681 of 4285
|
Post > |
Topic >> |
Re: I found a FORTH stack optimzer, but could use a better version.
by Bernd Paysan <bernd.paysan@[EMAIL PROTECTED]
>
Jan 6, 2008 at 11:02 PM
| foxchip wrote:
> 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?"
Yes, that's my goal. The reason is that with traditional, widely available
architectures, optimal code is too difficult to generate. I want to keep
my
compiler simple.
> When you write optimized code a peephole optimizer is useless. It can
> only improve non-optimal code.
But I don't write the code. I write Forth. The code is produced by a small
Forth program, which is not producing perfect code, because producing
perfect code on an 68k or x86 is too complex.
> 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.
Yes.
> 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.
I think that's the main purpose of an optimizer. But if you do a good
mapping from stack operations to registers, your OVER DROP DUP DROP SWAP +
DROP sequence will be optimized away, anyway. The question is: Is your
primary goal to eliminate code like this, or is it just a side-effect? I'm
ok if it's just a side-effect, but I wouldn't spent the effort if it was
the primary goal.
>> 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.
The target architectures are for sure architectures like x86 - i.e.
ac***ulated cruft from the past 40 years. I won't say that x86 is an
instruction set optimized for C, because such instruction sets have been
done, and they were a lot easier to target for "real native code"
compilers
than x86 is (x86_64 is slightly better, but not that much).
> 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.
I'm thinking about e.g. the LZ77 benchmark that comes with VFX-Forth.
There,
bigFORTH is about 5-10 times slower than VFX-Forth, while on all my "good"
benchmark code (which is more Forth-style than the LZ77 benchmark), the
factor is far less. On the other hand, I could just throw in my OOF
extension, and prove that VFX is a lot worse than bigFORTH, because the
source inliner of VFX doesn't work with my programming style in OOF and
therefore has to be disabled ;-).
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/


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

|
|
|
|