From 0895c53c41cfab6c1522b9b02ad9edb35b6724f2 Mon Sep 17 00:00:00 2001 From: rguenth Date: Sat, 20 Mar 2010 13:44:18 +0000 Subject: [PATCH] 2010-03-20 Richard Guenther PR rtl-optimization/43438 * combine.c (make_extraction): Properly zero-/sign-extend an extraction of the low part of a CONST_INT. Also handle CONST_DOUBLE. * gcc.c-torture/execute/pr43438.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157592 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/combine.c | 6 ++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/execute/pr43438.c | 23 +++++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr43438.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 77cc3ce..d753fb3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-03-20 Richard Guenther + + PR rtl-optimization/43438 + * combine.c (make_extraction): Properly zero-/sign-extend an + extraction of the low part of a CONST_INT. Also handle + CONST_DOUBLE. + 2010-03-19 Mike Stump * config/i386/darwin.h (SUBTARGET32_DEFAULT_CPU): Add. diff --git a/gcc/combine.c b/gcc/combine.c index f4f2fa0..a5240c9 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6793,8 +6793,10 @@ make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos, if (mode == tmode) return new_rtx; - if (CONST_INT_P (new_rtx)) - return gen_int_mode (INTVAL (new_rtx), mode); + if (CONST_INT_P (new_rtx) + || GET_CODE (new_rtx) == CONST_DOUBLE) + return simplify_unary_operation (unsignedp ? ZERO_EXTEND : SIGN_EXTEND, + mode, new_rtx, tmode); /* If we know that no extraneous bits are set, and that the high bit is not set, convert the extraction to the cheaper of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f0d88f0..22ea531 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-03-20 Richard Guenther + + PR rtl-optimization/43438 + * gcc.c-torture/execute/pr43438.c: New testcase. + 2010-03-20 Dodji Seketeli PR c++/43375 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr43438.c b/gcc/testsuite/gcc.c-torture/execute/pr43438.c new file mode 100644 index 0000000..aa901ce --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr43438.c @@ -0,0 +1,23 @@ +extern void abort (void); + +static unsigned char g_2 = 1; +static int g_9; +static int *l_8 = &g_9; + +static void func_12(int p_13) +{ + int * l_17 = &g_9; + *l_17 &= 0 < p_13; +} + +int main(void) +{ + unsigned char l_11 = 254; + *l_8 |= g_2; + l_11 |= *l_8; + func_12(l_11); + if (g_9 != 1) + abort (); + return 0; +} + -- 2.7.4