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]

[PATCH] Fix PR target/28946


Hello!

This patch fixes PR target/28946, a regression from gcc-2.95 (!)

As desdribed in the PR, for following testcase:

int fct1 (void);
int fct2 (void);

int
fct (unsigned nb)
{
 if ((nb >> 5) != 0)
   return fct1 ();
 else
   return fct2 ();
}

i386 backend emits spurious test instructions:

fct:
       movl 4(%esp), %eax
       shrl $5, %eax
       testl  %eax, %eax
       je  .L2
       jmp fct1
       .p2align 4,,7
.L2:
       jmp fct2

The problem is in combiner, which rejects PARALLEL combination of
arithmetic and CC setting instruction when the result of arithmetic
operation is unused. This is kind of strange, as the combination
_always_ results in smaller code, by avoiding explicit CC setting
insn.

The proposed solution is to force generation of PARALLEL of CC setting
and arith insn even when the result of arithmetic operation is unused.
Resulting asm code is then:

fct:
       movl 4(%esp), %eax
       shrl $5, %eax
       je  .L2
       jmp fct1
       .p2align 4,,7
.L2:
       jmp fct2

Patch was bootstrapped on i686-pc-linux-gnu, regtested for c, c++.


2006-09-06 Uros Bizjak <uros@kss-loka.si>


	PR target/28946
	* combine.c (try_combine): Force PARALLEL of comparison and
	arithmetic insn even if arithmetic result is not used.

testsuite/ChangeLog:

2006-09-06 Uros Bizjak <uros@kss-loka.si>

       PR target/28946
       * gcc.target/i386/pr28946.c: New test.

Uros.

Attachment: pr28946.diff
Description: Binary data

Attachment: pr28946.c
Description: Text document


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