Commit 5852948c by Richard Guenther Committed by Richard Biener

re PR tree-optimization/24689 (operand_equal_p does not return true for some equivalent ARRAY_REF)

2007-04-12  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/24689
	PR tree-optimization/31307
	* fold-const.c (operand_equal_p): Compare INTEGER_CST array
	indices by value.
	* gimplify.c (canonicalize_addr_expr): To be consistent with
	gimplify_compound_lval only set operands two and three of
	ARRAY_REFs if they are not gimple_min_invariant.  This makes
	it never at this place.
	* tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.

	* g++.dg/tree-ssa/pr31307.C: New testcase.
	* gcc.dg/tree-ssa/pr24689.c: Likewise.

From-SVN: r123736
parent d51347f9
2007-04-12 Richard Guenther <rguenther@suse.de>
PR tree-optimization/24689
PR tree-optimization/31307
* fold-const.c (operand_equal_p): Compare INTEGER_CST array
indices by value.
* gimplify.c (canonicalize_addr_expr): To be consistent with
gimplify_compound_lval only set operands two and three of
ARRAY_REFs if they are not gimple_min_invariant. This makes
it never at this place.
* tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
2007-04-11 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* pa.c (pa_som_asm_init_sections): Ensure that cfun->machine is not
......
......@@ -2884,9 +2884,13 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
case ARRAY_REF:
case ARRAY_RANGE_REF:
/* Operands 2 and 3 may be null. */
/* Operands 2 and 3 may be null.
Compare the array index by value if it is constant first as we
may have different types but same value here. */
return (OP_SAME (0)
&& OP_SAME (1)
&& (tree_int_cst_equal (TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg1, 1))
|| OP_SAME (1))
&& OP_SAME_WITH_NULL (2)
&& OP_SAME_WITH_NULL (3));
......
......@@ -1607,9 +1607,7 @@ canonicalize_addr_expr (tree *expr_p)
/* All checks succeeded. Build a new node to merge the cast. */
*expr_p = build4 (ARRAY_REF, dctype, obj_expr,
TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
TYPE_MIN_VALUE (TYPE_DOMAIN (datype)),
size_binop (EXACT_DIV_EXPR, TYPE_SIZE_UNIT (dctype),
size_int (TYPE_ALIGN_UNIT (dctype))));
NULL_TREE, NULL_TREE);
*expr_p = build1 (ADDR_EXPR, ctype, *expr_p);
}
......
2007-04-12 Richard Guenther <rguenther@suse.de>
PR tree-optimization/24689
PR tree-optimization/31307
* g++.dg/tree-ssa/pr31307.C: New testcase.
* gcc.dg/tree-ssa/pr24689.c: Likewise.
2007-04-12 Tobias Burnus <burnus@net-b.de>
PR fortran/31472
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
union MY_M128
{
double i;
};
struct RegFile
{
MY_M128 dst[4];
};
__inline__ __attribute__((always_inline)) static void
MEM_OPT_LOAD(MY_M128* reg, double* mem)
{
reg[0].i = *mem;
}
void _ia32_movntdq (double *, double);
__inline__ __attribute__((always_inline)) static void
MEM_OPT_STORE(MY_M128* reg, double* mem)
{
_ia32_movntdq ((double*)mem, (double)reg[0].i);
}
double _mm_adds_epu8 (double __A, double __B);
int test(unsigned char *d)
{
RegFile r;
MEM_OPT_LOAD((r.dst) , ((double*) d));
r.dst[0].i = _mm_adds_epu8(r.dst[0].i, r.dst[0].i);
MEM_OPT_STORE((r.dst), (double*) d);
return 0;
}
/* { dg-final { scan-tree-dump-not "r.dst" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
extern void bar (unsigned int);
int
foo (void)
{
char buf[1] = { 3 };
const char *p = buf;
const char **q = &p;
unsigned int ch;
switch (**q)
{
case 1: ch = 5; break;
default: ch = 0; break;
}
bar (ch);
return ch;
}
/* { dg-final { scan-tree-dump "return 0;" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
......@@ -1632,9 +1632,7 @@ maybe_fold_offset_to_array_ref (tree base, tree offset, tree orig_type)
if (!integer_zerop (elt_offset))
idx = int_const_binop (PLUS_EXPR, idx, elt_offset, 0);
return build4 (ARRAY_REF, orig_type, base, idx, min_idx,
size_int (tree_low_cst (elt_size, 1)
/ (TYPE_ALIGN_UNIT (elt_type))));
return build4 (ARRAY_REF, orig_type, base, idx, NULL_TREE, NULL_TREE);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment