This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Call force_to_mode on TRUNCATE's operand unconditionally
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 Jun 2009 09:08:55 -0700
- Subject: [PATCH] Call force_to_mode on TRUNCATE's operand unconditionally
This is a follow-up to this thread:
http://gcc.gnu.org/ml/gcc/2009-06/msg00332.html
The idea of the change was OK'ed there both by Jeff Law and Ian Taylor.
Bootstrapped and regtested on mips64octeon-linux and regtested on
mipsisa64r2-elf.
OK for trunk?
Adam
* combine.c (combine_simplify_rtx): Remove TRULY_NOOP_TRUNCATION
check when calling force_to_mode on TRUNCATE's operand.
testsuite/
* gcc.target/mips/truncate-3.c: New test.
Index: gcc/combine.c
===================================================================
--- gcc.orig/combine.c 2009-06-22 00:16:15.000000000 -0700
+++ gcc/combine.c 2009-06-22 08:58:43.000000000 -0700
@@ -4889,9 +4889,7 @@ combine_simplify_rtx (rtx x, enum machin
if (GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)
break;
- if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
- && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (mode),
- GET_MODE_BITSIZE (GET_MODE (XEXP (x, 0)))))
+ if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
SUBST (XEXP (x, 0),
force_to_mode (XEXP (x, 0), GET_MODE (XEXP (x, 0)),
GET_MODE_MASK (mode), 0));
Index: gcc/testsuite/gcc.target/mips/truncate-3.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.target/mips/truncate-3.c 2009-06-22 09:00:33.000000000 -0700
@@ -0,0 +1,11 @@
+/* Remove redundant operations in truncate's operand. */
+/* { dg-options "-O -mgp64" } */
+/* { dg-final { scan-assembler-not "\tandi?\t" } } */
+
+f (long long d)
+{
+ long long c = d & 0xffffffffff;
+ int i = (int) c;
+ g (i);
+}
+