http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59239
Bug ID: 59239
Summary: [SH] Improve decrement-and-test insn
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: olegendo at gcc dot gnu.org
Target: sh*-*-*
Created attachment 31264
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31264&action=edit
Possible cleanup patch
The decrement-and-test insn seems to rely on the define_peephole. At least
taking it out shows some missed opportunities in the CSiBE set.
I've tried replacing it with a define_peephole2, but it would still show missed
cases such as:
mov.l @(...), Rn
add #-1,Rn
mov.l Rn,@(...)
tst Rn,Rn
Towards the very end of compilation the insns often get reordered to something
like
mov.l @(...), Rn
add #-1,Rn
tst Rn,Rn
mov.l Rn,@(...)
and the define_peephole will catch it in the final RTL pass when outputting asm
code.
Attached is a patch that replaces the old define_peephole with a manual insn
combine in cmpeqsi_t. This catches some more of those cases where the
individual decrement and test insns are interleaved with something else.
There is one weird case in CSiBE in linux-2.4.23-pre3-testplatform/fs/iobuf.c
(alloc_kiobuf_bhs) though, where the individual decrement and test insns end up
in different basic blocks and only at the very end are emitted right next to
each other without a label in between.