diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4cc8a4c1b15..efa46766b4d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-09-24 Marc Glisse + + * 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 * tree-ssa-pre.c (bitmap_find_leader, create_expression_by_pieces, diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 4901b956774..7a4a6e8206c 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -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) \ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a2ea5084367..6d610e56909 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-09-24 Marc Glisse + + * gcc.dg/tree-ssa/forwprop-23.c: New testcase. + 2012-09-24 Richard Guenther PR middle-end/52173 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-23.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-23.c new file mode 100644 index 00000000000..52049933633 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-23.c @@ -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" } } */ diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 3b7991f8a1d..cd8f092915b 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -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;