* doc/tree-ssa.texi (Rough GIMPLE Grammar): Add missing rule.
* tree-gimple.c (is_gimple_min_invariant): Clarify head comment.
* tree-ssa-propagate.c (valid_gimple_expression_p): New
predicate, extracted from...
(set_rhs): ...here. Call it for the expression on entry.
* tree-ssa-propagate.h (valid_gimple_expression_p): Declare.
* tree-ssa-sccvn.c: Include tree-ssa-propagate.h.
(simplify_binary_expression): Use valid_gimple_expression_p
to validate the simplification.
* Makefile.in (tree-ssa-sccvn.o): Depends on tree-ssa-propagate.h.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126545
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-07-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR tree-optimization/32589
+ * doc/tree-ssa.texi (Rough GIMPLE Grammar): Add missing rule.
+ * tree-gimple.c (is_gimple_min_invariant): Clarify head comment.
+ * tree-ssa-propagate.c (valid_gimple_expression_p): New
+ predicate, extracted from...
+ (set_rhs): ...here. Call it for the expression on entry.
+ * tree-ssa-propagate.h (valid_gimple_expression_p): Declare.
+ * tree-ssa-sccvn.c: Include tree-ssa-propagate.h.
+ (simplify_binary_expression): Use valid_gimple_expression_p
+ to validate the simplification.
+ * Makefile.in (tree-ssa-sccvn.o): Depends on tree-ssa-propagate.h.
+
2007-07-11 Danny Smith <dannysmith@users.sourceforge.net>
* config/i386/cygming.h (PREFERRED_DEBUGGING_TYPE): Define to
DWARF2_DEBUG on 32 bit target too.
(DWARF2_UNWIND_INFO): Reorganize 64-bit vs 32-bit definition.
-
2007-07-11 Nick Clifton <nickc@redhat.com>
* config/m32r/m32r.h (INITIALIZE_TRAMPOLINE): Provide alternative
$(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) $(CFGLOOP_H) \
alloc-pool.h $(BASIC_BLOCK_H) bitmap.h $(HASHTAB_H) $(TREE_GIMPLE_H) \
- $(TREE_INLINE_H) tree-iterator.h tree-ssa-sccvn.h
+ $(TREE_INLINE_H) tree-iterator.h tree-ssa-propagate.h tree-ssa-sccvn.h
tree-vn.o : tree-vn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GGC_H) \
$(TREE_H) $(TREE_FLOW_H) $(HASHTAB_H) langhooks.h tree-pass.h \
$(TREE_DUMP_H) $(DIAGNOSTIC_H) tree-ssa-sccvn.h
-@c Copyright (c) 2004, 2005 Free Software Foundation, Inc.
+@c Copyright (c) 2004, 2005, 2007 Free Software Foundation, Inc.
@c Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
bitfieldref : BIT_FIELD_REF
op0 -> inner-compref
op1 -> CONST
- op2 -> var
+ op2 -> val
compref : inner-compref
| TARGET_MEM_REF
op1 -> val
val : ID
+ | invariant ADDR_EXPR
+ op0 -> addr-expr-arg
| CONST
rhs : lhs
+2007-07-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/invariant_index.ad[sb]: New test.
+
2007-07-11 Paolo Carlini <pcarlini@suse.de>
PR c++/32560
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-O -gnatp" }
+
+package body Invariant_Index is
+
+ procedure Proc (S : String) is
+ N : constant Integer := S'Length;
+ begin
+ Name_Buffer (1 + N .. Name_Len + N) := Name_Buffer (1 .. Name_Len);
+ Name_Buffer (1 .. N) := S;
+ Name_Len := Name_Len + N;
+ end;
+
+end Invariant_Index;
--- /dev/null
+package Invariant_Index is
+
+ Name_Buffer : String (1 .. 100);
+ Name_Len : Natural;
+
+ procedure Proc (S : String);
+
+end Invariant_Index;
|| INDIRECT_REF_P (t));
}
-/* Return true if T is function invariant. Or rather a restricted
+/* Return true if T is a GIMPLE minimal invariant. It's a restricted
form of function invariant. */
bool
}
-/* Set the main expression of *STMT_P to EXPR. If EXPR is not a valid
- GIMPLE expression no changes are done and the function returns
- false. */
+/* Return true if EXPR is a valid GIMPLE expression. */
bool
-set_rhs (tree *stmt_p, tree expr)
+valid_gimple_expression_p (tree expr)
{
- tree stmt = *stmt_p, op;
enum tree_code code = TREE_CODE (expr);
- stmt_ann_t ann;
- tree var;
- ssa_op_iter iter;
- /* Verify the constant folded result is valid gimple. */
switch (TREE_CODE_CLASS (code))
{
case tcc_declaration:
- if (!is_gimple_variable(expr))
+ if (!is_gimple_variable (expr))
return false;
break;
return false;
}
+ return true;
+}
+
+
+/* Set the main expression of *STMT_P to EXPR. If EXPR is not a valid
+ GIMPLE expression no changes are done and the function returns
+ false. */
+
+bool
+set_rhs (tree *stmt_p, tree expr)
+{
+ tree stmt = *stmt_p, op;
+ stmt_ann_t ann;
+ tree var;
+ ssa_op_iter iter;
+
+ if (!valid_gimple_expression_p (expr))
+ return false;
+
if (EXPR_HAS_LOCATION (stmt)
&& (EXPR_P (expr)
|| GIMPLE_STMT_P (expr))
/* In tree-ssa-propagate.c */
void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
tree get_rhs (tree);
+bool valid_gimple_expression_p (tree expr);
bool set_rhs (tree *, tree);
tree first_vdef (tree);
bool stmt_makes_single_load (tree);
#include "bitmap.h"
#include "langhooks.h"
#include "cfgloop.h"
+#include "tree-ssa-propagate.h"
#include "tree-ssa-sccvn.h"
/* This algorithm is based on the SCC algorithm presented by Keith
else if (SSA_VAL (op1) != VN_TOP && SSA_VAL (op1) != op1)
op1 = VN_INFO (op1)->valnum;
}
+
result = fold_binary (TREE_CODE (rhs), TREE_TYPE (rhs), op0, op1);
/* Make sure result is not a complex expression consisting
of operators of operators (IE (a + b) + (a + c))
Otherwise, we will end up with unbounded expressions if
fold does anything at all. */
- if (result)
- {
- if (is_gimple_min_invariant (result))
- return result;
- else if (SSA_VAR_P (result))
- return result;
- else if (EXPR_P (result))
- {
- switch (TREE_CODE_CLASS (TREE_CODE (result)))
- {
- case tcc_unary:
- {
- tree op0 = TREE_OPERAND (result, 0);
- if (!EXPR_P (op0))
- return result;
- }
- break;
- case tcc_binary:
- {
- tree op0 = TREE_OPERAND (result, 0);
- tree op1 = TREE_OPERAND (result, 1);
- if (!EXPR_P (op0) && !EXPR_P (op1))
- return result;
- }
- break;
- default:
- break;
- }
- }
- }
+ if (result && valid_gimple_expression_p (result))
+ return result;
+
return NULL_TREE;
}