This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix PR optimization/13653
> It seems to me that if the object is being set inside a loop, then
> it should never have had the unchanging bit set in the first place.
> Can you track down how that is happening?
/* We can set RTX_UNCHANGING_P from TREE_READONLY for decls whose
initialization is only executed once, or whose initializer always
has the same value. Currently we simplify this to PARM_DECLs in the
first case, and decls with TREE_CONSTANT initializers in the second.
if ((TREE_READONLY (t) && DECL_P (t)
&& (TREE_STATIC (t) || ! AGGREGATE_TYPE_P (TREE_TYPE (t)))
&& (TREE_CODE (t) == PARM_DECL
|| DECL_INITIAL (t) == NULL_TREE
|| TREE_CONSTANT (DECL_INITIAL (t))))
|| TREE_CODE_CLASS (TREE_CODE (t)) == 'c')
RTX_UNCHANGING_P (ref) = 1;
DECL_INITIAL is 0 here so the /u flag is set.
Note this note in loop_invariant_p:
/* We used to check RTX_UNCHANGING_P (x) here, but that is invalid
since the reg might be set by initialization within the loop. */
if ((x == frame_pointer_rtx || x == hard_frame_pointer_rtx
|| x == arg_pointer_rtx || x == pic_offset_table_rtx)
&& ! current_function_has_nonlocal_goto)
My understanding is that RTX_UNCHANGING_P used to be enough to return 1, but
was subsequently recognized as not sufficient.