aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2009-10-28 10:17:29 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2009-10-28 10:17:29 +0000
commit582021baa76be44ef884eebd0f7ab99599f4b890 (patch)
tree32ba5a71c0fa89fc4ecee255b75f7dee23b2b5cf /gcc
parent15e2a6c05ec5a600a8263ba1812d5dead9ba4aaf (diff)
downloadgcc-582021baa76be44ef884eebd0f7ab99599f4b890.zip
gcc-582021baa76be44ef884eebd0f7ab99599f4b890.tar.gz
gcc-582021baa76be44ef884eebd0f7ab99599f4b890.tar.bz2
re PR target/40741 (code size explosion for integer comparison)
2009-10-28 Paolo Bonzini <bonzini@gnu.org> PR rtl-optimization/40741 * config/arm/arm.c (thumb1_rtx_costs): IOR or XOR with a small constant is cheap. * config/arm/arm.md (andsi3, iorsi3): Try to place the result of force_reg on the LHS. (xorsi3): Likewise, and split the XOR if the constant is complex and not in Thumb mode. 2009-10-28 Paolo Bonzini <bonzini@gnu.org> PR rtl-optimization/40741 * gcc.target/arm/thumb-branch1.c: New. From-SVN: r153650
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/config/arm/arm.c2
-rw-r--r--gcc/config/arm/arm.md49
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/arm/thumb-branch1.c11
5 files changed, 69 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 63353b8..17793bf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
2009-10-28 Paolo Bonzini <bonzini@gnu.org>
+ PR rtl-optimization/40741
+ * config/arm/arm.c (thumb1_rtx_costs): IOR or XOR with
+ a small constant is cheap.
+ * config/arm/arm.md (andsi3, iorsi3): Try to place the result of
+ force_reg on the LHS.
+ (xorsi3): Likewise, and split the XOR if the constant is complex
+ and not in Thumb mode.
+
+2009-10-28 Paolo Bonzini <bonzini@gnu.org>
+
* expmed.c (emit_store_flag): Check costs before
transforming to the opposite representation.
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 35bd394..c22cfec 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -6215,7 +6215,7 @@ thumb1_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer)
else if ((outer == PLUS || outer == COMPARE)
&& INTVAL (x) < 256 && INTVAL (x) > -256)
return 0;
- else if (outer == AND
+ else if ((outer == IOR || outer == XOR || outer == AND)
&& INTVAL (x) < 256 && INTVAL (x) >= -256)
return COSTS_N_INSNS (1);
else if (outer == ASHIFT || outer == ASHIFTRT
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index e180c2f..fff41d8 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -1914,7 +1914,16 @@
else /* TARGET_THUMB1 */
{
if (GET_CODE (operands[2]) != CONST_INT)
- operands[2] = force_reg (SImode, operands[2]);
+ {
+ rtx tmp = force_reg (SImode, operands[2]);
+ if (rtx_equal_p (operands[0], operands[1]))
+ operands[2] = tmp;
+ else
+ {
+ operands[2] = operands[1];
+ operands[1] = tmp;
+ }
+ }
else
{
int i;
@@ -2623,7 +2632,16 @@
DONE;
}
else /* TARGET_THUMB1 */
- operands [2] = force_reg (SImode, operands [2]);
+ {
+ rtx tmp = force_reg (SImode, operands[2]);
+ if (rtx_equal_p (operands[0], operands[1]))
+ operands[2] = tmp;
+ else
+ {
+ operands[2] = operands[1];
+ operands[1] = tmp;
+ }
+ }
}
"
)
@@ -2731,12 +2749,29 @@
(define_expand "xorsi3"
[(set (match_operand:SI 0 "s_register_operand" "")
(xor:SI (match_operand:SI 1 "s_register_operand" "")
- (match_operand:SI 2 "arm_rhs_operand" "")))]
+ (match_operand:SI 2 "reg_or_int_operand" "")))]
"TARGET_EITHER"
- "if (TARGET_THUMB1)
- if (GET_CODE (operands[2]) == CONST_INT)
- operands[2] = force_reg (SImode, operands[2]);
- "
+ "if (GET_CODE (operands[2]) == CONST_INT)
+ {
+ if (TARGET_32BIT)
+ {
+ arm_split_constant (XOR, SImode, NULL_RTX,
+ INTVAL (operands[2]), operands[0], operands[1],
+ optimize && can_create_pseudo_p ());
+ DONE;
+ }
+ else /* TARGET_THUMB1 */
+ {
+ rtx tmp = force_reg (SImode, operands[2]);
+ if (rtx_equal_p (operands[0], operands[1]))
+ operands[2] = tmp;
+ else
+ {
+ operands[2] = operands[1];
+ operands[1] = tmp;
+ }
+ }
+ }"
)
(define_insn "*arm_xorsi3"
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6b1d818..aa64dab 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-28 Paolo Bonzini <bonzini@gnu.org>
+
+ PR rtl-optimization/40741
+ * gcc.target/arm/thumb-branch1.c: New.
+
2009-10-27 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/lambda/lambda-conv.C: New.
diff --git a/gcc/testsuite/gcc.target/arm/thumb-branch1.c b/gcc/testsuite/gcc.target/arm/thumb-branch1.c
new file mode 100644
index 0000000..c479d16
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/thumb-branch1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -mthumb -march=armv5te" } */
+
+int returnbool(int a, int b)
+{
+ if (a < b)
+ return 1;
+ return 0;
+}
+
+/* { dg-final { scan-assembler-not "eor" } } */