Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple trinary ops?

4 views
Skip to first unread message

Dan Sugalski

unread,
Jun 16, 2004, 12:28:57 PM6/16/04
to perl6-i...@perl.org
I'm wondering if it'd be useful enough to be worthwhile to have
non-flowcontrol min/max ops. Something like:

min P1, P2, P3
max P1, P2, P3

where P1 ends up with the lesser (or greater) of P2 and P3.

On the one hand this'd make some of the code I'm generating now
simpler, but on the other it'd only make one specific chunk simpler,
and I'm not sure that really warrants new ops.

Opinions?
--
Dan

--------------------------------------it's like this-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Brent 'Dax' Royal-Gordon

unread,
Jun 16, 2004, 1:08:58 PM6/16/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski wrote:
> min P1, P2, P3
> max P1, P2, P3
>
> Opinions?

Subroutine, man, subroutine. NCI if you need it to be fast.

--
Brent "Dax" Royal-Gordon <br...@brentdax.com>
Perl and Parrot hacker

Oceania has always been at war with Eastasia.

Dan Sugalski

unread,
Jun 16, 2004, 1:29:43 PM6/16/04
to Brent 'Dax' Royal-Gordon, perl6-i...@perl.org
At 10:08 AM -0700 6/16/04, Brent 'Dax' Royal-Gordon wrote:
>Dan Sugalski wrote:
>> min P1, P2, P3
>> max P1, P2, P3
>>
>>Opinions?
>
>Subroutine, man, subroutine. NCI if you need it to be fast.

Feh on a subroutine--it's three or four ops with a few branches.
Which was the point--it eliminates the branches.

P1 = P2
if P2 < P3 goto done
P1 = P3

or

if P2 < P3 goto useP2
P1 = P3
branch done
useP2:
P1 = P2
done:

depending on whether the extra assignment's an issue. Still, tosses
the branches. Probably not worth it, since it's not going to be used
too often by code generators.

Leopold Toetsch

unread,
Jun 16, 2004, 2:24:39 PM6/16/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> I'm wondering if it'd be useful enough to be worthwhile to have
> non-flowcontrol min/max ops. Something like:

> min P1, P2, P3
> max P1, P2, P3

Which cmp operation of the three we have? I smell opcode bloat.

> On the one hand this'd make some of the code I'm generating now
> simpler

dynops/dan.ops does exist already :)

leo

Dan Sugalski

unread,
Jun 16, 2004, 3:27:12 PM6/16/04
to l...@toetsch.at, perl6-i...@perl.org
At 8:24 PM +0200 6/16/04, Leopold Toetsch wrote:
>Dan Sugalski <d...@sidhe.org> wrote:
>> I'm wondering if it'd be useful enough to be worthwhile to have
>> non-flowcontrol min/max ops. Something like:
>
>> min P1, P2, P3
>> max P1, P2, P3
>
>Which cmp operation of the three we have? I smell opcode bloat.

Yeah, I've already given up on it. :)

Steve Fink

unread,
Jun 17, 2004, 12:10:44 PM6/17/04
to Dan Sugalski, l...@toetsch.at, perl6-i...@perl.org
On Jun-16, Dan Sugalski wrote:
> At 8:24 PM +0200 6/16/04, Leopold Toetsch wrote:
> >Dan Sugalski <d...@sidhe.org> wrote:
> >> I'm wondering if it'd be useful enough to be worthwhile to have
> >> non-flowcontrol min/max ops. Something like:
> >
> >> min P1, P2, P3
> >> max P1, P2, P3
> >
> >Which cmp operation of the three we have? I smell opcode bloat.
>
> Yeah, I've already given up on it. :)

### min P1, P2, P3 ###
isgt I0, P2, P3
choose P1, I0, P2, P3

0 new messages