re PR middle-end/21985 (miscompiled or wrong code snippet?)

PR middle-end/21985
	* fold-const.c (split_address_to_core_and_offset): Always return
	the address of the base object.

	* gcc.dg/tree-ssa/pr21985.c: New test.

From-SVN: r100877
This commit is contained in:
Zdenek Dvorak 2005-06-13 16:59:40 +02:00 committed by Zdenek Dvorak
parent 75d93ef719
commit adacecf105
4 changed files with 44 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2005-06-13 Zdenek Dvorak <dvorakz@suse.cz>
PR middle-end/21985
* fold-const.c (split_address_to_core_and_offset): Always return
the address of the base object.
2005-06-13 Bernd Schmidt <bernd.schmidt@analog.com>
* doc/invoke.texi (Blackfin Options): Document -mlong-calls.

View file

@ -11801,9 +11801,7 @@ split_address_to_core_and_offset (tree exp,
core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos,
poffset, &mode, &unsignedp, &volatilep,
false);
if (TREE_CODE (core) == INDIRECT_REF)
core = TREE_OPERAND (core, 0);
core = build_fold_addr_expr (core);
}
else
{

View file

@ -1,3 +1,8 @@
2005-06-13 Zdenek Dvorak <dvorakz@suse.cz>
PR middle-end/21985
* gcc.dg/tree-ssa/pr21985.c: New test.
2005-06-12 James A. Morrison <phython@gcc.gnu.org>
* ggcc.dg/pr14796-1.c: Add tests for (X << C) >> C.

View file

@ -0,0 +1,32 @@
/* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-vars" } */
struct
{
struct
{
int a;
int b;
} a[100];
} a;
void foo(unsigned);
unsigned *bar (void);
int
main (void)
{
unsigned *b = bar ();
/* This should be folded. */
foo (&a.a[50].a - &a.a[33].b);
foo ((unsigned) &a.a[50].b - (unsigned) &a);
/* And this should not. */
foo ((unsigned) &b - (unsigned) b);
return 0;
}
/* Two of the calls to foo should be folded to just foo(constant). */
/* { dg-final { scan-tree-dump-times "foo \\(\[0-9\]*\\)" 2 "vars" } } */