This is the mail archive of the 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: cc register usage on i386/2.96

While attempting to finally bootstrap/testsuite/commit the patch I've run
into problem with following testcase, that is not specific to my patch,
but wasn't trigered before:

f (j)
     int j;
  return ++j > 0;
main ()
  if (f ((~0U) >> 1))
    abort ();
  exit (0);

Interesting is the function f, that should return 0 when called for INT_MAX,
but it don't. Gcc correctly, according to the md file combines the arithmetic
with compare:

(insn 14 13 15 (parallel[ 
            (set (reg:CC 17 flags)
                (compare:CC (plus:SI (mem/f:SI (reg:SI 16 argp) 5)
                        (const_int 1 [0x1]))
                    (const_int 0 [0x0])))
            (clobber (scratch:SI))
        ] ) 120 {*addsi_5} (nil)
    (expr_list:REG_UNUSED (scratch:SI)
        (expr_list:REG_DEAD (reg:SI 16 argp)

(insn 15 14 17 (set (strict_low_part (subreg:QI (reg:SI 44) 0))
        (gt:QI (reg:CC 17 flags)
            (const_int 0 [0x0]))) 292 {*setcc_4} (insn_list 13 (insn_list 14 (nil)))
    (expr_list:REG_DEAD (reg:CC 17 flags)

Results in code:

	pushl	%ebp
	xorl	%eax, %eax
	movl	%esp, %ebp
	movl	8(%ebp), %edx
	popl	%ebp
	addl	$1, %edx
	setg	%al

But thinks don't work as expected and the overflow bit is set incorrectly.
It seems to me, that overflow is not set properly even for add/sub
instructions and thus we should disable the CCmode version of the patterns...


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