public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, ARM] PR47855 Compute attr "length" for some thumb2 insns
@ 2011-03-26 15:55 Carrot Wei
  2011-03-30  1:24 ` Ramana Radhakrishnan
  0 siblings, 1 reply; 16+ messages in thread
From: Carrot Wei @ 2011-03-26 15:55 UTC (permalink / raw)
  To: gcc-patches

Hi

As described in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47855, there are
many insn patterns don't compute attribute length correctly. This patch is the
first and simplest part of the fixing.

This patch has been tested on qemu.

thanks
Carrot


ChangeLog:
2011-03-26  Wei Guozhi  <carrot@google.com>

        PR target/47855
        * config/arm/arm.md (arm_cmpsi_insn): Compute attr "length".
        (arm_cond_branch): Likewise.
        (arm_cond_branch_reversed): Likewise.
        (arm_jump): Likewise.
        (push_multi): Likewise.


Index: arm.md
===================================================================
--- arm.md	(revision 171337)
+++ arm.md	(working copy)
@@ -7115,7 +7115,18 @@
   "@
    cmp%?\\t%0, %1
    cmn%?\\t%0, #%n1"
-  [(set_attr "conds" "set")]
+  [(set_attr "conds" "set")
+   (set (attr "length")
+     (if_then_else
+       (and (and (ne (symbol_ref "TARGET_THUMB2") (const_int 0))
+		 (eq (symbol_ref "which_alternative") (const_int 0)))
+	    (ior (ne (symbol_ref "REG_P (operands[1])") (const_int 0))
+		(and (ne (symbol_ref "CONST_INT_P (operands[1])") (const_int 0))
+		     (and (ge (symbol_ref "INTVAL (operands[1])") (const_int 0))
+			  (le (symbol_ref "INTVAL (operands[1])")
+			      (const_int 255))))))
+       (const_int 2)
+       (const_int 4)))]
 )

 (define_insn "*cmpsi_shiftsi"
@@ -7286,7 +7297,14 @@
   return \"b%d1\\t%l0\";
   "
   [(set_attr "conds" "use")
-   (set_attr "type" "branch")]
+   (set_attr "type" "branch")
+   (set (attr "length")
+	(if_then_else
+	   (and (ne (symbol_ref "TARGET_THUMB2") (const_int 0))
+		(and (ge (minus (match_dup 0) (pc)) (const_int -250))
+		     (le (minus (match_dup 0) (pc)) (const_int 256))))
+	   (const_int 2)
+	   (const_int 4)))]
 )

 (define_insn "*arm_cond_branch_reversed"
@@ -7305,7 +7323,14 @@
   return \"b%D1\\t%l0\";
   "
   [(set_attr "conds" "use")
-   (set_attr "type" "branch")]
+   (set_attr "type" "branch")
+   (set (attr "length")
+	(if_then_else
+	   (and (ne (symbol_ref "TARGET_THUMB2") (const_int 0))
+		(and (ge (minus (match_dup 0) (pc)) (const_int -250))
+		     (le (minus (match_dup 0) (pc)) (const_int 256))))
+	   (const_int 2)
+	   (const_int 4)))]
 )



@@ -7757,7 +7782,14 @@
     return \"b%?\\t%l0\";
   }
   "
-  [(set_attr "predicable" "yes")]
+  [(set_attr "predicable" "yes")
+   (set (attr "length")
+	(if_then_else
+	   (and (ne (symbol_ref "TARGET_THUMB2") (const_int 0))
+		(and (ge (minus (match_dup 0) (pc)) (const_int -2044))
+		     (le (minus (match_dup 0) (pc)) (const_int 2048))))
+	   (const_int 2)
+	   (const_int 4)))]
 )

 (define_insn "*thumb_jump"
@@ -10256,7 +10288,26 @@

     return \"\";
   }"
-  [(set_attr "type" "store4")]
+  [(set_attr "type" "store4")
+   (set (attr "length")
+	(if_then_else
+	   (and (ne (symbol_ref "TARGET_THUMB2") (const_int 0))
+		(ne (symbol_ref "{
+		    int i, regno, hi_reg;
+		    int num_saves = XVECLEN (operands[2], 0);
+		    regno = REGNO (operands[1]);
+		    hi_reg = (REGNO_REG_CLASS (regno) == HI_REGS)
+			     && (regno != LR_REGNUM);
+		    for (i = 1; i < num_saves; i++)
+		      {
+			regno = REGNO (XEXP (XVECEXP (operands[2], 0, i), 0));
+			hi_reg |= (REGNO_REG_CLASS (regno) == HI_REGS)
+				  && (regno != LR_REGNUM);
+		      }
+		    !hi_reg;    }")
+		  (const_int 0)))
+	   (const_int 2)
+	   (const_int 4)))]
 )

 (define_insn "stack_tie"

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-04-08  9:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-26 15:55 [PATCH, ARM] PR47855 Compute attr "length" for some thumb2 insns Carrot Wei
2011-03-30  1:24 ` Ramana Radhakrishnan
2011-03-30  7:35   ` Chung-Lin Tang
2011-03-30 12:41     ` Richard Earnshaw
2011-03-31  3:34   ` Carrot Wei
2011-03-31 16:04     ` Ramana Radhakrishnan
2011-04-01  6:57       ` Carrot Wei
2011-04-05 13:32         ` Ramana Radhakrishnan
2011-04-06  2:26           ` Carrot Wei
2011-04-07  9:32         ` Richard Sandiford
2011-04-07 11:09           ` Carrot Wei
2011-04-07 11:31             ` Ramana Radhakrishnan
2011-04-08  7:36               ` Carrot Wei
2011-04-08  8:36                 ` Ramana Radhakrishnan
2011-04-08  8:52                   ` Carrot Wei
2011-04-08  9:01                     ` Ramana Radhakrishnan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).