I have remembered the name correctly, haven't I?

Would it gain us much implementing De Morgan's theorem in the peephole
optimiser?

nick@Bagpuss [nick]$ perl -le 'for $l (0,1) {for $r (0, 1) {print 0+(!$l && !$r) }}'
1
0
0
0
nick@Bagpuss [nick]$ perl -le 'for $l (0,1) {for $r (0, 1) {print 0+!($l || $r) }}'
1
0
0
0

nick@Bagpuss [nick]$ perl -MO=Terse -e 'print 0+(!$l && !$r)'
LISTOP (0x164048) leave [1]
    OP (0x164070) enter
    COP (0x164008) nextstate
    LISTOP (0x163fc0) print
        OP (0x163fe8) pushmark
        BINOP (0x163f98) add [1]
            SVOP (0x163db0) const  IV (0xed2b8) 0
            UNOP (0x163f78) null
                LOGOP (0x10db20) and
                    UNOP (0x163e68) not
                        UNOP (0x163e48) null [15]
                            SVOP (0x163dd0) gvsv  GV (0x10a974) *l
                    UNOP (0x163f58) not
                        UNOP (0x163f38) null [15]
                            SVOP (0x163e88) gvsv  GV (0x10a98c) *r
-e syntax OK
nick@Bagpuss [nick]$ perl -MO=Terse -e 'print 0+!($l || $r)'
LISTOP (0x164028) leave [1]
    OP (0x164050) enter
    COP (0x163fe8) nextstate
    LISTOP (0x163fa0) print
        OP (0x163fc8) pushmark
        BINOP (0x163f78) add [1]
            SVOP (0x163db0) const  IV (0xed2b8) 0
            UNOP (0x163f58) not
                UNOP (0x163f38) null
                    LOGOP (0x10db20) or
                        UNOP (0x163e48) null [15]
                            SVOP (0x163dd0) gvsv  GV (0x10a974) *l
                        UNOP (0x163f18) null [15]
                            SVOP (0x163e68) gvsv  GV (0x10a98c) *r
-e syntax OK


For "much" equal to 1 op in total.

I think that the answer is "no, do it by hand if it matters that much",
doesn't it?

This also might be a perl6 question, for a more "serious" -O2 optimiser.
Hmm. Would parrot benefit from nand and nor ops?

[beware of cross posting when replying]

Nicholas Clark
-- 
EMCFT http://www.ccl4.org/~nick/CV.html

Reply via email to