bit test instruction
Jeff Law
law@redhat.com
Thu Jan 22 05:44:00 GMT 2015
On 01/21/15 19:35, James Bowman wrote:
> My target has a bit test (btst) instruction, so the C code:
>
> if (x & 256)
>
> can be efficiently coded as (for example):
>
> btst $r0,256
> jmp nz,.L1
>
> However, with my current patterns, it generates an explicit "and" and
> "compare" using a scratch:
>
> and $r1,$r0,256
> cmp $r1,0
> jmp nz,.L1
>
> Looking through targets with a similar instruction - arc, rx, s390,
> i386 - I see several different approaches. They all seem quite
> complicated.
>
> What is the best way of implementing this? Thanks.
PA also has a bit test, both constant and variable position.
(define_insn ""
[(set (pc)
(if_then_else
(ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
(const_int 1)
(match_operand:SI 1 "uint5_operand" ""))
(const_int 0))
(label_ref (match_operand 2 "" ""))
(pc)))]
That's the constant position test. There's a similar pattern for
testing at a variable position.
jeff
More information about the Gcc-help
mailing list