This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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?

It's maybe_set_unchanging:

  /* 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
      || 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:

    case REG:
      /* 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)
	return 1;

My understanding is that RTX_UNCHANGING_P used to be enough to return 1, but 
was subsequently recognized as not sufficient.

Eric Botcazou

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]