OK, thanks for your answer.
Is there other instruction for backward jumps that can be used
to replace cmp to zero+bne?

btw, in the following link of thumb-2 instructions set I understood that
the label can appear before the branch so it was confusing...

CB{N}Z Rn,<label> If Rn {== or !=} 0 then PC := label. label is (this
instruction + 4-130).

http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf

Thanks,
Revital




From:   Chung-Lin Tang <clt...@codesourcery.com>
To:     Revital1 Eres/Haifa/i...@ibmil
Cc:     linaro-toolchain@lists.linaro.org
Date:   29/11/2010 10:21 AM
Subject:        Re: A question about thumb2 cbnz/cbz implementation in
            thumb2.md



Unfortunately, cbnz/cbz has a 6-bit:'0' (7-bit aligned to 2) immediate
offset that is *zero extended*, i.e. it is only for forward branches.

Chung-Lin

On 2010/11/29 下午 04:14, Revital1 Eres wrote:
>
> Hello,
>
> I have a question about cbnz/cbz thumb-2 instruction implementation in
> thumb2.md file:
>
> I have an example where we jump to a label which appears before the
branch;
> for example:
>
>          L4
>          ...
>          cmp     r3, 0
>          bne     .L4
>
> It seems that cbnz instruction should be applied in this loop; replacing
> cmp+bne; however, cbnz fails to be applied as diff = ADDRESS (L4) -
ADDRESS
> (bne .L4) is negative and according to thumb2_cbz in thumb2.md it should
> be 2<=diff<=128 (please see snippet below taken from thumb2_cbz).
>
> So I want to double check if the current implementation of thumb2_cbnz
> in thumb2.md needs to be changed to enable it.
>
> The following is from thumb2_cbnz in thumb2.md:
>
>    [(set (attr "length")
>          (if_then_else
>              (and (ge (minus (match_dup 1) (pc)) (const_int 2))
>                   (le (minus (match_dup 1) (pc)) (const_int 128))
>                   (eq (symbol_ref ("which_alternative")) (const_int 0)))
>              (const_int 2)
>              (const_int 8)))]
>
> Thanks,
> Revital
>
>
> _______________________________________________
> linaro-toolchain mailing list
> linaro-toolchain@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/linaro-toolchain




_______________________________________________
linaro-toolchain mailing list
linaro-toolchain@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-toolchain

Reply via email to