This is the mail archive of the gcc-patches@gcc.gnu.org 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: [PR target/20126, RFC] loop DEST_ADDR biv replacement may fail


Hi Alexandre,

On 12 Apr 2005, Alexandre Oliva wrote:
> Does any expert in rtl loop care to chime in?

I'm not sure I qualify for the title "rtl loop" expert, but setting
bl->all_reduced to zero after we fail to validate a change to the
RTL looks to be a reasonable failure mode.

I still like your fallbacks, that by trying harder we perform better
optimization, but as shown by the ARM's "stmia" instruction I suspect
there will always be cases were we can't reduce IV expressions in
some backend instructions.

Previously, we didn't even detect these cases and potentially generated
bad code.  I think the ICE was an improvement over the "potentially" bad
code, but what we really need is a more graceful failure/degradation.


As you propose, I'd recommend something like (for your final clause):

	/* If it wasn't a reg, create a pseudo and use that.  */
	rtx reg, seq;
	start_sequence ();
	reg = force_reg (v->mode, *v->location);
!	if (validate_change_maybe_volatile (v->insn, v->location, reg))
!	  {
!	    seq = get_insns ();
!	    end_sequence ();
!	    loop_insn_emit_before (loop, 0, v->insn, seq);
!	  }
!	else
!	  {
!	    end_sequence ();
!	    if (loop_dump_stream)
!	      fprintf (loop_dump_stream,
!		       "unable to reduce iv to register in insn %d\n",
!		       INSN_UID (v->insn));
!	    bl->all_reduced = 0;
!	    v->ignore = 1;
!	    continue;
!	  }


I think its worthwhile keeping the validate_change_maybe_volatile
calls/changes on mainline.  But then for gcc 4.0.0 or 4.0.1
we can use the much simpler:


      if (v->giv_type == DEST_ADDR)
        /* Store reduced reg as the address in the memref where we found
           this giv.  */
!	{
!	  if (!validate_change (v->insn, v->location, v->new_reg, 0))
!	    {
!             if (loop_dump_stream)
!               fprintf (loop_dump_stream,
!                        "unable to reduce iv to register in insn %d\n",
!                        INSN_UID (v->insn));
!             bl->all_reduced = 0;
!             v->ignore = 1;
!             continue;
!	    }
!	}


A much less intrusive regression fix than previously proposed fix for
4.0.  But perhaps one of the real "rtl loop" experts would like to
comment?

Roger
--


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