This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
collapsing insns leading to a branch to a single branch-on-bit-equality insn
- From: Brendan Kehoe <brendan at zen dot org>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 21 Jan 2003 15:26:05 +0000
- Subject: collapsing insns leading to a branch to a single branch-on-bit-equality insn
- Reply-to: brendan at zen dot org
I'm exploring an architecture has an insn similar to branch-on-bit-set like
the i960's bbs* and bbc* insns. But it's in fact an instruction that
compares the low 8 bits on two 32-bit values, and branches on their equality.
(Not on whether or not they are set.)
Thus what I'm doing is like
if ((Ra & 0xff) == (Rb & 0xff))
foo();
But trying to take multiple instructions, including an if_then_else, and
collapse that down doesn't seem to be very easy.
The insns are:
(insn 18 16 19 (set (reg:SI 75)
(and:SI (reg/v:SI 70)
(const_int 255 [0xff]))) -1 (nil)
(nil))
(insn 19 18 20 (set (reg:SI 76)
(and:SI (reg/v:SI 71)
(const_int 255 [0xff]))) -1 (nil)
(nil))
(insn 20 19 21 (set (reg:SI 77)
(eq:SI (reg:SI 75)
(reg:SI 76))) -1 (nil)
(nil))
(jump_insn 21 20 23 (set (pc)
(if_then_else (ne:SI (reg:SI 77)
(const_int 0 [0x0]))
(pc)
(label_ref 24))) -1 (nil)
(nil))
In theory, that would become something that could be like (but obviously not
the same as):
(define_insn "branch8bits"
[
(set (match_operand:SI 2 "register_operand" "=r")
(and:SI (match_operand:SI 0 "register_operand" "r")
(const_int 255)))
(set (match_operand:SI 3 "register_operand" "=r")
(and:SI (match_operand:SI 1 "register_operand" "r")
(const_int 255)))
(set (match_operand:SI 4 "register_operand" "=r")
(eq:SI (match_dup 2) (match_dup 3)))
(set (pc) (if_then_else
(ne:SI (match_dup 4) (const_int 0))
(pc)
(label_ref (match_operand 5 "" ""))
))
]
""
"branch8bits %0, %1, %l5")
Trying define_peephole didn't do it; I used a define_expand to hit on the
pattern and call something like gen_branch8bits_insn, but that also didn't
get used.
The proximity of any instructions to the compare insn & the jump insn appear
to be irrelevant. Nothing wants to accept something like this.
I trolled through the other MD files, but found nothing really doing the same
thing. Is such a pattern too complex to be recognized?
B
--
Brendan Kehoe brendan@zen.org
http://www.zen.org/~brendan/