From dce31f4655bb5e9e592c8d925850f28b089c5c74 Mon Sep 17 00:00:00 2001 From: nemet Date: Sat, 18 Jul 2009 21:55:40 +0000 Subject: [PATCH] * combine.c (make_compound_operation) : 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149781 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/combine.c | 6 ++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/mips/ext-2.c | 14 ++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/mips/ext-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c087253..8ad42bf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2009-07-18 Adam Nemet + * combine.c (make_compound_operation) : If force_to_mode + re-expanded the compound use gen_lowpart instead to convert to the + desired mode. + +2009-07-18 Adam Nemet + * combine.c (try_widen_shift_mode): Add COUNT, OUTER_CODE and OUTER_CONST arguments. : Use them to allow widening if the bits shifted in from diff --git a/gcc/combine.c b/gcc/combine.c index 39daf28..3f39bc3 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3200817..b1f8698 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2009-07-18 Adam Nemet + * gcc.target/mips/ext-2.c: New test. + +2009-07-18 Adam Nemet + * gcc.target/mips/octeon-exts-7.c: New test. * gcc.target/mips/octeon-exts-2.c: Revert previous change. * gcc.target/mips/octeon-exts-5.c: Likewise. diff --git a/gcc/testsuite/gcc.target/mips/ext-2.c b/gcc/testsuite/gcc.target/mips/ext-2.c new file mode 100644 index 0000000..8d502b2 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/ext-2.c @@ -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); +} -- 2.7.4