Karl Meakin <karl.mea...@arm.com> writes:
> Extract the hardcoded values for the minimum PC-relative displacements
> into named constants and document them.
>
> gcc/ChangeLog:
>
>       * config/aarch64/aarch64.md (BRANCH_LEN_P_128MiB): New constant.
>       (BRANCH_LEN_N_128MiB): Likewise.
>       (BRANCH_LEN_P_1MiB): Likewise.
>       (BRANCH_LEN_N_1MiB): Likewise.
>       (BRANCH_LEN_P_32KiB): Likewise.
>       (BRANCH_LEN_N_32KiB): Likewise.
> ---
>  gcc/config/aarch64/aarch64.md | 64 ++++++++++++++++++++++++++---------
>  1 file changed, 48 insertions(+), 16 deletions(-)
>
> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
> index d79b74924d4..c4c23dc3669 100644
> --- a/gcc/config/aarch64/aarch64.md
> +++ b/gcc/config/aarch64/aarch64.md
> @@ -704,7 +704,23 @@ (define_insn "jump"
>    [(set_attr "type" "branch")]
>  )
>  
> +;; Maximum PC-relative positive/negative displacements for various branching
> +;; instructions.
> +(define_constants
> +  [
> +    ;; +/- 128MiB.  Used by B, BL.
> +    (BRANCH_LEN_P_128MiB  134217724)
> +    (BRANCH_LEN_N_128MiB -134217728)
> +

Sorry to be awkward, but: I was in the process of applying 1-5 locally
with a view to pushing them when I noticed that this was never actually
used, and isn't likely to be used in the foreseeable future.  Would you
mind dropping it?  I don't think we should add dead code.

Thanks,
Richard

> +    ;; +/- 1MiB.  Used by B.<cond>, CBZ, CBNZ.
> +    (BRANCH_LEN_P_1MiB  1048572)
> +    (BRANCH_LEN_N_1MiB -1048576)
>  
> +    ;; +/- 32KiB.  Used by TBZ, TBNZ.
> +    (BRANCH_LEN_P_32KiB  32764)
> +    (BRANCH_LEN_N_32KiB -32768)
> +  ]
> +)
>  
>  ;; -------------------------------------------------------------------
>  ;; Conditional jumps
> @@ -769,13 +785,17 @@ (define_insn "aarch64_bcond"
>    }
>    [(set_attr "type" "branch")
>     (set (attr "length")
> -     (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
> -                        (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
> +     (if_then_else (and (ge (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_N_1MiB))
> +                        (lt (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_P_1MiB)))
>                     (const_int 4)
>                     (const_int 8)))
>     (set (attr "far_branch")
> -     (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
> -                        (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
> +     (if_then_else (and (ge (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_N_1MiB))
> +                        (lt (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_P_1MiB)))
>                     (const_int 0)
>                     (const_int 1)))]
>  )
> @@ -830,13 +850,17 @@ (define_insn "aarch64_cbz<optab><mode>1"
>    }
>    [(set_attr "type" "branch")
>     (set (attr "length")
> -     (if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -1048576))
> -                        (lt (minus (match_dup 1) (pc)) (const_int 1048572)))
> +     (if_then_else (and (ge (minus (match_dup 1) (pc))
> +                            (const_int BRANCH_LEN_N_1MiB))
> +                        (lt (minus (match_dup 1) (pc))
> +                            (const_int BRANCH_LEN_P_1MiB)))
>                     (const_int 4)
>                     (const_int 8)))
>     (set (attr "far_branch")
> -     (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
> -                        (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
> +     (if_then_else (and (ge (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_N_1MiB))
> +                        (lt (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_P_1MiB)))
>                     (const_int 0)
>                     (const_int 1)))]
>  )
> @@ -870,13 +894,17 @@ (define_insn "*aarch64_tbz<optab><mode>1"
>    }
>    [(set_attr "type" "branch")
>     (set (attr "length")
> -     (if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -32768))
> -                        (lt (minus (match_dup 1) (pc)) (const_int 32764)))
> +     (if_then_else (and (ge (minus (match_dup 1) (pc))
> +                            (const_int BRANCH_LEN_N_32KiB))
> +                        (lt (minus (match_dup 1) (pc))
> +                            (const_int BRANCH_LEN_P_32KiB)))
>                     (const_int 4)
>                     (const_int 8)))
>     (set (attr "far_branch")
> -     (if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -1048576))
> -                        (lt (minus (match_dup 1) (pc)) (const_int 1048572)))
> +     (if_then_else (and (ge (minus (match_dup 1) (pc))
> +                            (const_int BRANCH_LEN_N_1MiB))
> +                        (lt (minus (match_dup 1) (pc))
> +                            (const_int BRANCH_LEN_P_1MiB)))
>                     (const_int 0)
>                     (const_int 1)))]
>  )
> @@ -931,13 +959,17 @@ (define_insn "@aarch64_tbz<optab><ALLI:mode><GPI:mode>"
>    }
>    [(set_attr "type" "branch")
>     (set (attr "length")
> -     (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
> -                        (lt (minus (match_dup 2) (pc)) (const_int 32764)))
> +     (if_then_else (and (ge (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_N_32KiB))
> +                        (lt (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_P_32KiB)))
>                     (const_int 4)
>                     (const_int 8)))
>     (set (attr "far_branch")
> -     (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
> -                        (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
> +     (if_then_else (and (ge (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_N_1MiB))
> +                        (lt (minus (match_dup 2) (pc))
> +                            (const_int BRANCH_LEN_P_1MiB)))
>                     (const_int 0)
>                     (const_int 1)))]

Reply via email to