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: RFA: MN10300: Add support for SETLB and Lcc instructions


> +  /* If the comparison has not already been split out of the branch
> +     then do so now.  */
> +  if (REGNO (cmp_reg) != CC_REG)
> +    {
> +      rtx cmp;
> +
> +      cmp = emit_insn_before (gen_cmpsi (cmp_reg, XEXP (comparison, 1)), branch);
> +
> +      DUMP ("Extracted comparison from branch:", cmp);
> +    }

This should never ever fire.  These should have been split already,
at least with optimization, on which this pass is dependant.  Just
assert here, if you like.

> +mn10300_block_contains_call (struct basic_block_def * block)

  basic_block block

> +  for (insn = block->il.rtl->head_;
> +       insn != NULL_RTX;
> +       insn = NEXT_INSN (insn))
> +    {
> +      if (CALL_P (insn))
> +	return true;
> +
> +      if (insn == block->il.rtl->end_)
> +	break;
> +    }

  FOR_BB_INSNS (block, insn)
    if (CALL_P (insn))
      return true;

> +  df_analyze ();
> +  if (flow_loops_find (& loops) > 0)
> +    {
> +      unsigned int i;
> +      loop_p loop;
> +
> +      FOR_EACH_VEC_ELT (loop_p, loops.larray, i, loop)

You need compute_bb_for_insn, and to set up current_loops.
Then you can use 

  FOR_EACH_LOOP(liter, loop, LI_ONLY_INNERMOST)

instead of iterating over the array by hand.  This will eliminate
at least the fake loop and non-innermost loop check that you do
by hand.  Of course, current_loops must be cleared at the end.

> +	  else if (loop->header != loop->latch)
> +	    reason = "it is not a simple do-while loop";

Why?  A loop with multiple blocks should be fine with Lcc.
I do see that you've got loop->header and loop->latch backward
further below; perhaps that was your reason for this?

> +	      rtx branch = loop->header->il.rtl->end_;

  BB_END (loop->latch)

> +	      if (single_set (branch) == NULL_RTX
> +		  || GET_CODE (SET_SRC (single_set (branch))) != IF_THEN_ELSE)

  !any_condjump_p (branch)

> +		  label = loop->latch->il.rtl->head_;

  BB_HEAD (loop->header)

> +		  /* If necessary, extract the label from the branch insn.  */
> +		  if (! LABEL_P (label))

This should never ever fire -- how else can the loop have been created?
Again, you can just assert here.

> +      /* FIXME: Calling flow_loops_free() appears to be the correct thing to do,
> +	 but it results in a seg-fault when building regex.c in the target libiberty
> +	 library.  I have no idea why; so I have disabled the call for now.  */
> +      /* flow_loops_free (& loops); */

I'm having a look into this.  It's definitely non-obvious...


r~


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