This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Peepholes obsolete / new peepholes
- To: "gnuh8" <gnuh8 at pcserv dot demon dot co dot uk>, "gcc" <gcc at gcc dot gnu dot org>
- Subject: Peepholes obsolete / new peepholes
- From: Ralf Gütlein <ralf dot guetlein at aranea dot de>
- Date: Mon, 14 Aug 2000 10:49:38 +0200
- Cc: "Kazu Hirata" <kazu at hxi dot com>
- Reply-To: Ralf Gütlein <ralf dot guetlein at biotest-mt dot de>
Peepholes obsolete (?)
The peephole definitions in h8300.md cc pre-decrement and
post-increment memory accesses seem to be obsolete. Apparently,
the regarding optimizations are done in an earlier step already.
I temporarily removed those peepholes and all my test cases
still produced optimal code. Also, couldn't find any
different compiler output in a fairly large project.
PATCH:
Clear all current peephole definitions from h8300.md
New Peepholes
Following (admittedly rare) case produced sub-optimal code with
can be improved by new peepholes:
void pushb(char b, char *p)
{
*--p = b;
}
void pushw(int w, int *p)
{
*--p = w;
}
compiler output:
_pushb:
mov.b r0l,@(-1,r1)
rts
_pushw:
mov.w r0,@(-2,r1)
rts
The reason for the non-optimal output is that the compiler assumes
it could save one instruction (the decrements). Unfortunately, it
added 2 bytes to the optimal instruction size (the offsets).
after patch:
_pushb:
mov.b r0l,@-r1
rts
_pushw:
mov.w r0,@-r1
rts
PATCH:
add the following to h8300.md
;; Notice a move which could be pre-decremented.
;; byte
(define_peephole2
[(set (mem:HI (plus:HI (match_operand:HI 1 "register_operand" "r")
(const_int -2)))
(match_operand:HI 0 "register_operand" "r"))]
"(find_reg_note (insn, REG_DEAD, operands[1]) && (REGNO(operands[1]) !=
REGNO(operands[0])))"
[(set (mem:SI (pre_dec:HI (match_dup 1)))
(match_dup 0))]
"")
;; word
(define_peephole2
[(set (mem:QI (plus:HI (match_operand:HI 1 "register_operand" "r")
(const_int -1)))
(match_operand:QI 0 "register_operand" "r"))]
"(find_reg_note (insn, REG_DEAD, operands[1]) && (REGNO(operands[1]) !=
REGNO(operands[0])))"
[(set (mem:QI (pre_dec:HI (match_dup 1)))
(match_dup 0))]
"")
.....
ô ô )
-----oOOo--(_)---oOOo------
Ralf Guetlein
Biotest Medizintechnik GmbH
Industriestrasse 19
D-63755 Alzenau
Germany
---------------------------
Tel. +49 6023 9487-42
Fax. +49 6023 9487-33
ralf.guetlein@biotest-mt.de
---------------------------