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: [PATCH] Fix PR optimization/6822


On Thu, May 30, 2002 at 11:16:03PM +0200, Eric Botcazou wrote:
>  * config/i386/i386.c (ix86_expand_int_movcc): When trying to convert
>  a LEU or a GTU, use GET_MODE_MASK to check the second operand. Use
>  get_int_mode to truncate it to the right mode after incrementing it.

I actually lied to you about using GET_MODE_MASK.  We're interested
in the maximum value for a mode, and since constants are always sign
extended, this is always -1.

The revised patch that I applied is attached.

> Should the testcase go in torture/compile, or dg to restrict it to i386 ?

Nothing x86 specific about it.  Therefore we run it everywhere.
Installed as compile/20020530-1.c.

>  pushl %ebp
>  movl %esp, %ebp
>  pushl %eax
>  pushl %eax
>  call foo1
[...]
> The ifcvt pass has devised a clever way to eliminate the conditional jump,
> but it looks like the two stack slots thus freed haven't been deleted.

That's actually stack alignment for the call to foo.


r~


        * config/i386/i386.c (ix86_expand_int_movcc): Don't cast INTVAL
        to unsigned int for op1 comparisons.  Use gen_int_mode.

Index: i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.368.2.12
diff -c -p -d -r1.368.2.12 i386.c
*** i386.c	29 May 2002 20:34:21 -0000	1.368.2.12
--- i386.c	30 May 2002 23:02:09 -0000
*************** ix86_expand_int_movcc (operands)
*** 7963,7973 ****
    if ((code == LEU || code == GTU)
        && GET_CODE (ix86_compare_op1) == CONST_INT
        && mode != HImode
!       && (unsigned int) INTVAL (ix86_compare_op1) != 0xffffffff
!       /* The operand still must be representable as sign extended value.  */
        && (!TARGET_64BIT
  	  || GET_MODE (ix86_compare_op0) != DImode
! 	  || (unsigned int) INTVAL (ix86_compare_op1) != 0x7fffffff)
        && GET_CODE (operands[2]) == CONST_INT
        && GET_CODE (operands[3]) == CONST_INT)
      {
--- 7963,7974 ----
    if ((code == LEU || code == GTU)
        && GET_CODE (ix86_compare_op1) == CONST_INT
        && mode != HImode
!       && INTVAL (ix86_compare_op1) != -1
!       /* For x86-64, the immediate field in the instruction is 32-bit
! 	 signed, so we can't increment a DImode value above 0x7fffffff.  */
        && (!TARGET_64BIT
  	  || GET_MODE (ix86_compare_op0) != DImode
! 	  || INTVAL (ix86_compare_op1) != 0x7fffffff)
        && GET_CODE (operands[2]) == CONST_INT
        && GET_CODE (operands[3]) == CONST_INT)
      {
*************** ix86_expand_int_movcc (operands)
*** 7975,7981 ****
  	code = LTU;
        else
  	code = GEU;
!       ix86_compare_op1 = GEN_INT (INTVAL (ix86_compare_op1) + 1);
      }
  
    start_sequence ();
--- 7976,7983 ----
  	code = LTU;
        else
  	code = GEU;
!       ix86_compare_op1 = gen_int_mode (INTVAL (ix86_compare_op1) + 1,
! 				       GET_MODE (ix86_compare_op0));
      }
  
    start_sequence ();


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