From: Richard Guenther Date: Tue, 20 Apr 2010 13:09:42 +0000 (+0000) Subject: re PR rtl-optimization/43438 (possible wrong code bug) X-Git-Tag: releases/gcc-4.3.5~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1a597aef307523a256c38f33f1d666fa59a9148;p=thirdparty%2Fgcc.git re PR rtl-optimization/43438 (possible wrong code bug) 2010-04-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. * gcc.c-torture/execute/pr43438.c: New testcase. From-SVN: r158555 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c8d59b35b91c..794475166e07 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-04-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. + 2010-04-20 Richard Guenther PR tree-optimization/43629 diff --git a/gcc/combine.c b/gcc/combine.c index 5d8239d0d9c0..49246d35f623 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6552,7 +6552,8 @@ make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos, return new; if (GET_CODE (new) == CONST_INT) - return gen_int_mode (INTVAL (new), mode); + return simplify_unary_operation (unsignedp ? ZERO_EXTEND : SIGN_EXTEND, + mode, new, 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 bbbee43d9860..45553b688a1a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-20 Richard Guenther + + PR rtl-optimization/43438 + * gcc.c-torture/execute/pr43438.c: New testcase. + 2010-04-20 Richard Guenther PR tree-optimization/43629 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 000000000000..aa901ce0f904 --- /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; +} +