This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Fix out-of-range branches in Thumb-2 mode
- From: mitchell at codesourcery dot com (Mark Mitchell)
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 10 Jul 2009 16:18:28 -0700 (PDT)
- Subject: PATCH: Fix out-of-range branches in Thumb-2 mode
- Reply-to: mark at codesourcery dot com
This patch fixes a situation where we underestimated the length of the
cbz and cbnz patterns, resulting in out-of-range branches.
Tested on arm-linux-gnueabi, approved by Paul Brook offline, and
applied to mainline.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2009-07-10 Mark Mitchell <mark@codesourcery.com>
* config/arm/thumb2.md (thumb2_cbz): Correct computation of length
attribute.
(thumb2_cbnz): Likewise.
Index: config/arm/thumb2.md
===================================================================
--- config/arm/thumb2.md (revision 149500)
+++ config/arm/thumb2.md (working copy)
@@ -1325,7 +1325,7 @@
(clobber (reg:CC CC_REGNUM))]
"TARGET_THUMB2"
"*
- if (get_attr_length (insn) == 2 && which_alternative == 0)
+ if (get_attr_length (insn) == 2)
return \"cbz\\t%0, %l1\";
else
return \"cmp\\t%0, #0\;beq\\t%l1\";
@@ -1333,7 +1333,8 @@
[(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)))
+ (le (minus (match_dup 1) (pc)) (const_int 128))
+ (eq (symbol_ref ("which_alternative")) (const_int 0)))
(const_int 2)
(const_int 8)))]
)
@@ -1347,7 +1348,7 @@
(clobber (reg:CC CC_REGNUM))]
"TARGET_THUMB2"
"*
- if (get_attr_length (insn) == 2 && which_alternative == 0)
+ if (get_attr_length (insn) == 2)
return \"cbnz\\t%0, %l1\";
else
return \"cmp\\t%0, #0\;bne\\t%l1\";
@@ -1355,7 +1356,8 @@
[(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)))
+ (le (minus (match_dup 1) (pc)) (const_int 128))
+ (eq (symbol_ref ("which_alternative")) (const_int 0)))
(const_int 2)
(const_int 8)))]
)