backport: re PR rtl-optimization/43438 (possible wrong code bug)

Backport from mainline:
	2010-03-20  Richard Guenther  <rguenther@suse.de>

	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.

From-SVN: r157634
This commit is contained in:
Jakub Jelinek 2010-03-22 16:05:46 +01:00 committed by Jakub Jelinek
parent c2c70960cc
commit a41d163c75
4 changed files with 40 additions and 3 deletions

View File

@ -1,6 +1,13 @@
2010-03-22 Jakub Jelinek <jakub@redhat.com>
Backport from mainline:
2010-03-20 Richard Guenther <rguenther@suse.de>
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 Michael Matz <matz@suse.de>
PR c++/43116

View File

@ -1,6 +1,6 @@
/* Optimize by combining instructions for GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GCC.
@ -6531,8 +6531,10 @@ make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos,
if (mode == tmode)
return new_rtx;
if (GET_CODE (new_rtx) == CONST_INT)
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

View File

@ -1,6 +1,11 @@
2010-03-22 Jakub Jelinek <jakub@redhat.com>
Backport from mainline:
2010-03-20 Richard Guenther <rguenther@suse.de>
PR rtl-optimization/43438
* gcc.c-torture/execute/pr43438.c: New testcase.
2010-03-19 Michael Matz <matz@suse.de>
PR c++/43116

View File

@ -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;
}