arm.c (thumb1_size_rtx_costs): Assign proper cost for shift_add/shift_sub0/shift_sub1...
authorTerry Guo <terry.guo@arm.com>
Thu, 25 Jul 2013 04:10:27 +0000 (04:10 +0000)
committerXuepeng Guo <xguo@gcc.gnu.org>
Thu, 25 Jul 2013 04:10:27 +0000 (04:10 +0000)
gcc/ChangeLog:
2013-07-24  Terry Guo  <terry.guo@arm.com>

* config/arm/arm.c (thumb1_size_rtx_costs): Assign proper cost for
shift_add/shift_sub0/shift_sub1 RTXs.

gcc/testsuite/ChangeLog:
2013-07-24  Terry Guo  <terry.guo@arm.com>

* gcc.target/arm/thumb1-Os-mult.c: New test case.

From-SVN: r201237

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/thumb1-Os-mult.c [new file with mode: 0644]

index 0aed48dc1fb44d5ad49bf7c07b032f95a98afdcd..fa582e306b1000282001ea69bb1d5e87d3ad7c21 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-25  Terry Guo  <terry.guo@arm.com>
+
+       * config/arm/arm.c (thumb1_size_rtx_costs): Assign proper cost for
+       shift_add/shift_sub0/shift_sub1 RTXs.
+
 2013-07-24  Bill Schmidt  <wschmidt@linux.ibm.com>
            Anton Blanchard <anton@au1.ibm.com>
 
index ad5446927d47a72f93ec57f708eb9c2b88bcadd3..294de80a73b29a0548425a1c66ec3743af0441ae 100644 (file)
@@ -7925,6 +7925,15 @@ thumb1_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer)
 
     case PLUS:
     case MINUS:
+      /* Thumb-1 needs two instructions to fulfill shiftadd/shiftsub0/shiftsub1
+        defined by RTL expansion, especially for the expansion of
+        multiplication.  */
+      if ((GET_CODE (XEXP (x, 0)) == MULT
+          && power_of_two_operand (XEXP (XEXP (x,0),1), SImode))
+         || (GET_CODE (XEXP (x, 1)) == MULT
+             && power_of_two_operand (XEXP (XEXP (x, 1), 1), SImode)))
+       return COSTS_N_INSNS (2);
+      /* On purpose fall through for normal RTX.  */
     case COMPARE:
     case NEG:
     case NOT:
index 1cfb5a4f945f172c61955a32dd8f663fc846f310..b8bd8609e51f0473e61454eb475bfc69b8e1d610 100644 (file)
@@ -1,3 +1,7 @@
+2013-07-25  Terry Guo  <terry.guo@arm.com>
+
+       * gcc.target/arm/thumb1-Os-mult.c: New test case.
+
 2013-07-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/57942
diff --git a/gcc/testsuite/gcc.target/arm/thumb1-Os-mult.c b/gcc/testsuite/gcc.target/arm/thumb1-Os-mult.c
new file mode 100644 (file)
index 0000000..31b8bd6
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-require-effective-target arm_thumb1_ok } */
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+/* { dg-skip-if "" { ! { arm_thumb1 } } } */
+
+int
+mymul3 (int x)
+{
+  return x * 0x555;
+}
+
+/* { dg-final { scan-assembler "mul\[\\t \]*r.,\[\\t \]*r." } } */