Following suggestions I'm testing the attached emitting the following
for long branches where LE cannot cover:
subs lr, #1
bmi .L2
>From 0cd38cb29829b48f96e8e060e7a875f49236b67b Mon Sep 17 00:00:00 2001
From: Andrea Corallo <[email protected]>
Date: Wed, 3 Feb 2021 15:21:54 +0100
Subject: [PATCH] arm: Add low overhead loop address range check [PR98931]
2021-02-05 Andrea Corallo <[email protected]>
* config/arm/thumb2.md: Generate alternative sequence for long
range branches.
---
gcc/config/arm/thumb2.md | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md
index bd53bf320de..a8327066bfe 100644
--- a/gcc/config/arm/thumb2.md
+++ b/gcc/config/arm/thumb2.md
@@ -1719,7 +1719,18 @@
(set (reg:SI LR_REGNUM)
(plus:SI (reg:SI LR_REGNUM) (const_int -1)))])]
"TARGET_32BIT && TARGET_HAVE_LOB"
- "le\t%|lr, %l0")
+ "*
+ if (get_attr_length (insn) == 2)
+ return \"le\\t%|lr, %l0\";
+ else
+ return \"subs\\t%|lr, #1\;bmi\\t%l0\";
+ "
+ [(set (attr "length")
+ (if_then_else
+ (lt (minus (pc) (match_dup 0)) (const_int 1024))
+ (const_int 2)
+ (const_int 6)))
+ (set_attr "type" "branch")])
(define_expand "doloop_begin"
[(match_operand 0 "" "")
--
2.20.1