]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
simplify-rtx.c (simplify_unary_operation_1 <case TRUNCATE>): A truncate of a memory...
authorAndrew Pinski <apinski@cavium.com>
Sat, 1 Sep 2012 18:52:19 +0000 (18:52 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sat, 1 Sep 2012 18:52:19 +0000 (11:52 -0700)
2012-09-01  Andrew Pinski  <apinski@cavium.com>

* simplify-rtx.c (simplify_unary_operation_1 <case TRUNCATE>):
A truncate of a memory is just loading the low part of the memory.

2012-09-01  Andrew Pinski  <apinski@cavium.com>

        * gcc.target/mips/truncate-8.c: New testcase.

From-SVN: r190848

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/truncate-8.c [new file with mode: 0644]

index 14b923c1f3a991279ca20f3c96c81ae89f681559..45325cb3e9de997f380d1246381939152c2128a2 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-01  Andrew Pinski  <apinski@cavium.com>
+
+       * simplify-rtx.c (simplify_unary_operation_1 <case TRUNCATE>):
+       A truncate of a memory is just loading the low part of the memory.
+
 2012-09-01  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/46829
index a878048ac979bfd8f73d35d1db94bb3cce1d1a96..f59150ee2c1f9f4ec01555bd5bdc85197c590b14 100644 (file)
@@ -869,6 +869,14 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op)
          && COMPARISON_P (op)
          && (STORE_FLAG_VALUE & ~GET_MODE_MASK (mode)) == 0)
        return rtl_hooks.gen_lowpart_no_emit (mode, op);
+
+      /* A truncate of a memory is just loading the low part of the memory
+        if we are not changing the meaning of the address. */
+      if (GET_CODE (op) == MEM
+         && !MEM_VOLATILE_P (op)
+         && !mode_dependent_address_p (XEXP (op, 0)))
+       return rtl_hooks.gen_lowpart_no_emit (mode, op);
+
       break;
 
     case FLOAT_TRUNCATE:
index c5f88b77415c8ba12db9f89af0d32cd7a4e31660..648b014af690473fc4b4e2b20349f50e604f1d82 100644 (file)
@@ -1,3 +1,7 @@
+2012-09-01  Andrew Pinski  <apinski@cavium.com>
+
+       * gcc.target/mips/truncate-8.c: New testcase.
+
 2012-09-01  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/46829
diff --git a/gcc/testsuite/gcc.target/mips/truncate-8.c b/gcc/testsuite/gcc.target/mips/truncate-8.c
new file mode 100644 (file)
index 0000000..f172b22
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-options "-mgp64" } */
+/* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */
+/* { dg-final { scan-assembler "\tlw\t" } } */
+/* { dg-final { scan-assembler-not "\tsll\t" } } */
+/* { dg-final { scan-assembler-not "\tld\t" } } */
+
+struct s
+{
+  long long a;
+  int b;
+};
+
+int
+foo (struct s *x)
+{
+  return x->a;
+}
+