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