From 6c98269caade6f1688dce794bffaf3f5bcfb7463 Mon Sep 17 00:00:00 2001 From: Richard Earnshaw Date: Mon, 15 Jan 2001 16:17:08 +0000 Subject: [PATCH] arm.md (cbranchsi4): Correct calculation of branch ranges. * arm.md (cbranchsi4): Correct calculation of branch ranges. (negated_cbranchsi4): Likewise. From-SVN: r39039 --- gcc/ChangeLog | 5 +++++ gcc/config/arm/arm.md | 25 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1fb8a66..c70dc0a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2001-01-15 Richard Earnshaw + * arm.md (cbranchsi4): Correct calculation of branch ranges. + (negated_cbranchsi4): Likewise. + +2001-01-15 Richard Earnshaw + * config/arm/semi.h (SUBTARGET_EXTRA_SPECS): Define. (SUBTARGET_EXTRA_ASM_SPEC): Define to empty string. (ASM_SPEC): Call subtarget_extra_asm_spec. Don't diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index f7d4e6d..103d5ad 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -5520,7 +5520,22 @@ -;; Comapre & branch insns +;; Compare & branch insns +;; The range calcualations are based as follows: +;; For forward branches, the address calculation returns the address of +;; the next instruction. This is 2 beyond the branch instruction. +;; For backward branches, the address calculation returns the address of +;; the first instruction in this pattern (cmp). This is 2 before the branch +;; instruction for the shortest sequence, and 4 before the branch instruction +;; if we have to jump around an unconditional branch. +;; To the basic branch range the PC offset must be added (this is +4). +;; So for forward branches we have +;; (pos_range - pos_base_offs + pc_offs) = (pos_range - 2 + 4). +;; And for backward branches we have +;; (neg_range - neg_base_offs + pc_offs) = (neg_range - (-2 or -4) + 4). +;; +;; For a 'b' pos_range = 2046, neg_range = -2048 giving (-2040->2048). +;; For a 'b' pos_range = 254, neg_range = -256 giving (-250 ->256). (define_insn "cbranchsi4" [(set (pc) @@ -5552,7 +5567,7 @@ (const_int 4) (if_then_else (and (ge (minus (match_dup 3) (pc)) (const_int -2040)) - (le (minus (match_dup 3) (pc)) (const_int 2054))) + (le (minus (match_dup 3) (pc)) (const_int 2048))) (const_int 6) (const_int 8))))] ) @@ -5583,11 +5598,11 @@ (set (attr "length") (if_then_else (and (ge (minus (match_dup 3) (pc)) (const_int -250)) - (le (minus (match_dup 3) (pc)) (const_int 254))) + (le (minus (match_dup 3) (pc)) (const_int 256))) (const_int 4) (if_then_else - (and (ge (minus (match_dup 3) (pc)) (const_int -2044)) - (le (minus (match_dup 3) (pc)) (const_int 2044))) + (and (ge (minus (match_dup 3) (pc)) (const_int -2040)) + (le (minus (match_dup 3) (pc)) (const_int 2048))) (const_int 6) (const_int 8))))] ) -- 2.7.4