]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
combine.c (make_compound_operation): If force_to_mode re-expanded the compound use...
authorAdam Nemet <anemet@caviumnetworks.com>
Sat, 18 Jul 2009 21:55:40 +0000 (21:55 +0000)
committerAdam Nemet <nemet@gcc.gnu.org>
Sat, 18 Jul 2009 21:55:40 +0000 (21:55 +0000)
* combine.c (make_compound_operation) <SUBREG>: If force_to_mode
re-expanded the compound use gen_lowpart instead to convert to the
desired mode.

testsuite/
* gcc.target/mips/ext-2.c: New test.

From-SVN: r149781

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/mips/ext-2.c [new file with mode: 0644]

index c087253a80a7f7e89c1665d6496ac99fdcbcf766..8ad42bf6ac5b12acf9f5e2210f621cf571f7e097 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-18  Adam Nemet  <anemet@caviumnetworks.com>
+
+       * combine.c (make_compound_operation) <SUBREG>: If force_to_mode
+       re-expanded the compound use gen_lowpart instead to convert to the
+       desired mode.
+
 2009-07-18  Adam Nemet  <anemet@caviumnetworks.com>
 
        * combine.c (try_widen_shift_mode): Add COUNT, OUTER_CODE and
index 39daf2881d4f45402e049e1eff477f89ba354395..3f39bc3b286a1193c0a30b47bcb535d71fb492dd 100644 (file)
@@ -7061,6 +7061,12 @@ make_compound_operation (rtx x, enum rtx_code in_code)
            if (GET_CODE (newer) != SUBREG)
              newer = make_compound_operation (newer, in_code);
 
+           /* force_to_mode can expand compounds.  If it just re-expanded the
+              compound use gen_lowpart instead to convert to the desired
+              mode.  */
+           if (rtx_equal_p (newer, x))
+             return gen_lowpart (GET_MODE (x), tem);
+
            return newer;
          }
 
index 3200817c4e1efb63bcad9b76d92ec2a0dce40966..b1f86982294f0ea71ed0fa35755c2ef66fdd6474 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-18  Adam Nemet  <anemet@caviumnetworks.com>
+
+       * gcc.target/mips/ext-2.c: New test.
+
 2009-07-18  Adam Nemet  <anemet@caviumnetworks.com>
 
        * gcc.target/mips/octeon-exts-7.c: New test.
diff --git a/gcc/testsuite/gcc.target/mips/ext-2.c b/gcc/testsuite/gcc.target/mips/ext-2.c
new file mode 100644 (file)
index 0000000..8d502b2
--- /dev/null
@@ -0,0 +1,14 @@
+/* Turn the truncate,zero_extend,lshiftrt sequence before the or into a
+   zero_extract.  The truncate is due to TARGET_PROMOTE_PROTOTYPES, the
+   zero_extend to PROMOTE_MODE.  */
+/* { dg-do compile } */
+/* { dg-options "-O isa_rev>=2 -mgp64" } */
+/* { dg-final { scan-assembler "\tdext\t" } } */
+/* { dg-final { scan-assembler-not "and" } } */
+/* { dg-final { scan-assembler-not "srl" } } */
+
+void
+f (unsigned char x, unsigned char *r)
+{
+  *r = 0x50 | (x >> 4);
+}