------- Comment #3 from ebotcazou at gcc dot gnu dot org 2007-07-03 13:10 ------- Reduced testcase:
package P is Name_Buffer : String (1 .. 100); Name_Len : Natural; procedure Proc (S : String); end P; package body P 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 P; Fallout of: 2007-06-30 Daniel Berlin <[EMAIL PROTECTED]> Fix PR tree-optimization/32540 Fix PR tree-optimization/31651 * tree-ssa-sccvn.c: New file. * tree-ssa-sccvn.h: Ditto. Value numbering D.759_64 stmt = D.759_64 = &p__name_buffer[1]{lb: 1 sz: 1} + n_32; RHS &p__name_buffer[1]{lb: 1 sz: 1} + n_32 simplified to &p__name_buffer[(<unnamed-signed:32>) MAX_EXPR <D.738_31, 0> + 1]{lb: 1 sz: 1} has constants 0 The replacement expression is is_gimple_min_invariant because TREE_INVARIANT so simplify_binary_expression accepts it: /* Make sure result is not a complex expression consiting 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; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32589