I386 strlen "fix" (giveup)

Jan Hubicka hubicka@atrey.karlin.mff.cuni.cz
Mon Mar 6 12:39:00 GMT 2000


Hi
I've spent last four hours by trying to get builtins.c working right on
failing strlen expander. It still don't work, so I gave up. 
This patch fixes and disables the problematic piece of code in i386.md
Maybe someone else will be able to add the necesary functionality. I think
this is reasonable solulution even if no one manage to do it.  This restores
behaviour gcc had for a years.

I apologize for all problems this change caused.  The problem was perfectly
masked for me by inline version of strlen defined in glibc.

Honza

Mon Mar  6 21:17:00 MET 2000  Jan Hubicka  <jh@suse.cz>
	* i386.md (strlensi): Fix and disable test to avoid expanding of generic
	unrolled strlen.

Index: egcs/gcc/config/i386/i386.md
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.md,v
retrieving revision 1.140
diff -c -3 -p -r1.140 i386.md
*** i386.md	2000/03/01 11:15:52	1.140
--- i386.md	2000/03/06 20:15:28
***************
*** 8591,8614 ****
    ""
    "
  {
!   rtx out, addr, eoschar, align, scratch1, scratch2, scratch3;
  
    /* The generic case of strlen expander is long.  Avoid it's
       expanding unless TARGET_INLINE_ALL_STRINGOPS.  */
  
!   if (TARGET_UNROLL_STRLEN && eoschar == const0_rtx && optimize > 1
        && !optimize_size
        && (GET_CODE (align) != CONST_INT || INTVAL (align) < 4))
      FAIL;
  
    out = operands[0];
    addr = force_reg (Pmode, XEXP (operands[1], 0));
-   eoschar = operands[2];
-   align = operands[3];
    scratch1 = gen_reg_rtx (SImode);
  
!   if (TARGET_UNROLL_STRLEN && eoschar == const0_rtx && optimize > 1
!       && !optimize_size)
      {
        /* Well it seems that some optimizer does not combine a call like
  	     foo(strlen(bar), strlen(bar));
--- 8591,8619 ----
    ""
    "
  {
!   rtx out, addr, scratch1, scratch2, scratch3;
!   rtx eoschar = operands[2];
!   rtx align = operands[3];
  
+  /* The strlen pattern can't fail currently.  Once this is fixed in builtins.c
+     we can enable this code.  */
+ #if 0
    /* The generic case of strlen expander is long.  Avoid it's
       expanding unless TARGET_INLINE_ALL_STRINGOPS.  */
  
!   if (TARGET_UNROLL_STRLEN
!       && eoschar == const0_rtx
        && !optimize_size
+       && !TARGET_INLINE_ALL_STRINGOPS
        && (GET_CODE (align) != CONST_INT || INTVAL (align) < 4))
      FAIL;
+ #endif
  
    out = operands[0];
    addr = force_reg (Pmode, XEXP (operands[1], 0));
    scratch1 = gen_reg_rtx (SImode);
  
!   if (TARGET_UNROLL_STRLEN && eoschar == const0_rtx && !optimize_size)
      {
        /* Well it seems that some optimizer does not combine a call like
  	     foo(strlen(bar), strlen(bar));


More information about the Gcc-patches mailing list