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]

Re: fix strlensi in i386.md


> 
> 2.) Assuming the gen_strlensi () expander is correct in using
>     FAIL then the above code would need to be written
> 
I think it is. All expanders except those mentioned in explicitly in the docs
IMO ought to have choice to FAIL.
At least i386 is expample of sane us for this feature.
MO
>     expanded_rtx = GEN_FCN (icode)(result, ...);
>     if (!expanded_rtx)
>        return NULL_RTX;
>     emit_insn (expanded_rtx);
> 
> 
>     But this in itself can cause aborts in expand_expr ()
>     if the rtl being expanded has a RTL_EXPR with a non-zero 
>     RTL_EXPR_SEQUENCE (). 
> 
>     The abort occurs because the when expand_expr processes a RTL_EXPR
>     with a non-zero RTL_EXPR_SEQUENCE() it finds it's value is const0_rtx.
> 
>     Note that when expand_expr processing a RTL_EXPR with a non zero 
>     RTL_EXPR_SEQUENCE() has the side effect of setting the RTL_EXPR_SEQUENCE () 
>     to const0_rtx.
> 
>     I found that RTL_EXPR node was being expanded twice the 1st time via a
>     call to expand_expr() in expand_builtin_strlen() and subsequently if the
>     MD expander bailed out using FAIL a call to expand_expr() in expand_call().
I must say, that it is completly unclear to me what are you trying to say
here. Thats purpose why I originally didn't attempted to fix the problem and
expected someone more familiar with this mecanizm to take a look on it.
I've made fix I am attaching at the end. It seems to do the trick for me
and at least in trivial examples it results in correct code at least in
trivial examples with strlen expander containing FAIL.

Please can you take a look at it and try to explain me the problem with
such solution if still present?

Thanks
The code is inspired by similar concept present in memset expander.


*** builtins.c.old	Sun Mar  5 16:25:22 2000
--- builtins.c	Sun Mar  5 16:26:07 2000
*************** expand_builtin_strlen (exp, target, mode
*** 1299,1304 ****
--- 1299,1306 ----
      return 0;
    else
      {
+       rtx pat;
+       rtx last = get_last_insn ();
        tree src = TREE_VALUE (arglist);
        tree len = c_strlen (src);
  
*************** expand_builtin_strlen (exp, target, mode
*** 1362,1370 ****
        if (! (*insn_data[(int)icode].operand[2].predicate) (char_rtx, char_mode))
  	char_rtx = copy_to_mode_reg (char_mode, char_rtx);
  
!       emit_insn (GEN_FCN (icode) (result,
! 				  gen_rtx_MEM (BLKmode, src_rtx),
! 				  char_rtx, GEN_INT (align));
  
        /* Return the value in the proper mode for this function.  */
        if (GET_MODE (result) == value_mode)
--- 1364,1378 ----
        if (! (*insn_data[(int)icode].operand[2].predicate) (char_rtx, char_mode))
  	char_rtx = copy_to_mode_reg (char_mode, char_rtx);
  
!       pat = GEN_FCN (icode) (result,
! 			     gen_rtx_MEM (BLKmode, src_rtx),
! 			     char_rtx, GEN_INT (align));
!       if (!pat)
! 	{
! 	  delete_insns_since (last);
! 	  return 0;
! 	}
!       emit_insn (pat);
  
        /* Return the value in the proper mode for this function.  */
        if (GET_MODE (result) == value_mode)


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