tree-ssa-forwprop.c: Include tree-ssa-propagate.h.

2012-09-24  Marc Glisse  <marc.glisse@inria.fr>

gcc/
	* tree-ssa-forwprop.c: Include tree-ssa-propagate.h.
	(simplify_bitfield_ref): Handle constructors.
	* Makefile.in (tree-ssa-forwprop.o): Depend on tree-ssa-propagate.h.

gcc/testsuite/
	* gcc.dg/tree-ssa/forwprop-23.c: New testcase.

From-SVN: r191665
This commit is contained in:
Marc Glisse 2012-09-24 14:43:43 +02:00 committed by Marc Glisse
parent e076271b02
commit f2167d6813
5 changed files with 46 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2012-09-24 Marc Glisse <marc.glisse@inria.fr>
* tree-ssa-forwprop.c: Include tree-ssa-propagate.h.
(simplify_bitfield_ref): Handle constructors.
* Makefile.in (tree-ssa-forwprop.o): Depend on tree-ssa-propagate.h.
2012-09-24 Richard Guenther <rguenther@suse.de>
* tree-ssa-pre.c (bitmap_find_leader, create_expression_by_pieces,

View File

@ -2246,7 +2246,7 @@ tree-ssa-forwprop.o : tree-ssa-forwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) $(CFGLOOP_H) \
$(TREE_FLOW_H) $(TREE_PASS_H) $(DIAGNOSTIC_H) \
langhooks.h $(FLAGS_H) $(GIMPLE_H) $(GIMPLE_PRETTY_PRINT_H) $(EXPR_H) \
$(OPTABS_H)
$(OPTABS_H) tree-ssa-propagate.h
tree-ssa-phiprop.o : tree-ssa-phiprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) \
$(TREE_FLOW_H) $(TREE_PASS_H) $(DIAGNOSTIC_H) \

View File

@ -1,3 +1,7 @@
2012-09-24 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/forwprop-23.c: New testcase.
2012-09-24 Richard Guenther <rguenther@suse.de>
PR middle-end/52173

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-forwprop1" } */
typedef long vec __attribute__ ((vector_size (2 * sizeof (long))));
long f (long d, long e)
{
vec x = { d, e };
vec m = { 1, 0 };
return __builtin_shuffle (x, m) [1];
}
/* { dg-final { scan-tree-dump-not "BIT_FIELD_REF" "forwprop1" } } */
/* { dg-final { cleanup-tree-dump "forwprop1" } } */

View File

@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
#include "expr.h"
#include "cfgloop.h"
#include "optabs.h"
#include "tree-ssa-propagate.h"
/* This pass propagates the RHS of assignment statements into use
sites of the LHS of the assignment. It's basically a specialized
@ -2582,25 +2583,35 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
|| TREE_CODE (TREE_TYPE (op0)) != VECTOR_TYPE)
return false;
def_stmt = get_prop_source_stmt (op0, false, NULL);
if (!def_stmt || !can_propagate_from (def_stmt))
return false;
op1 = TREE_OPERAND (op, 1);
op2 = TREE_OPERAND (op, 2);
code = gimple_assign_rhs_code (def_stmt);
if (code == CONSTRUCTOR)
{
tree tem = fold_ternary (BIT_FIELD_REF, TREE_TYPE (op),
gimple_assign_rhs1 (def_stmt), op1, op2);
if (!tem || !valid_gimple_rhs_p (tem))
return false;
gimple_assign_set_rhs_from_tree (gsi, tem);
update_stmt (gsi_stmt (*gsi));
return true;
}
elem_type = TREE_TYPE (TREE_TYPE (op0));
if (TREE_TYPE (op) != elem_type)
return false;
size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type));
op1 = TREE_OPERAND (op, 1);
n = TREE_INT_CST_LOW (op1) / size;
if (n != 1)
return false;
def_stmt = get_prop_source_stmt (op0, false, NULL);
if (!def_stmt || !can_propagate_from (def_stmt))
return false;
op2 = TREE_OPERAND (op, 2);
idx = TREE_INT_CST_LOW (op2) / size;
code = gimple_assign_rhs_code (def_stmt);
if (code == VEC_PERM_EXPR)
{
tree p, m, index, tem;