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 4.8, i386]: Enable post-reload compare optimization pass (PR28685)


Hello!

Attached patch enables post-reload compare optimization pass for x86 targets.

As shown in following test, patch removes redundant compare:

--cut here--
int test(int a, int b)
{
  int lt = a < b;
  int eq = a == b;
  if (lt)
    return 1;
  return eq;
}
--cut here--

gcc -O2 on x86_64, a cmove target:

test:
        xorl    %edx, %edx
        cmpl    %esi, %edi
        movl    $1, %eax
        sete    %dl
        cmovge  %edx, %eax
        ret

gcc-O2 -fno-compare-elim:

test:
        xorl    %edx, %edx
        cmpl    %esi, %edi
        movl    $1, %eax
        sete    %dl
        cmpl    %esi, %edi
        cmovge  %edx, %eax
        ret

2012-02-05  Uros Bizjak  <ubizjak@gmail.com>

	PR target/28685
	* config/i386/i386.c (TARGET_FLAGS_REGNUM): New.

testsuite/ChangeLog:

	PR target/28685
	* gcc.target/i386/pr28685.c: New test.

The patch was tested on x86_64-pc-linux-gnu {,-m32}. The patch will be
committed to 4.8 once stage 1 opens.

Uros.

Attachment: p.diff.txt
Description: Text document


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