public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/2][GCC] Add one more pattern to RTL if-conversion
@ 2016-05-23 13:53 Mikhail Maltsev
  2016-05-23 13:58 ` [PATCH 1/2][GCC] Refactor noce_try_store_flag_constants Mikhail Maltsev
  2016-05-23 14:00 ` [PATCH 2/2][GCC] Add one more pattern to RTL if-conversion Mikhail Maltsev
  0 siblings, 2 replies; 7+ messages in thread
From: Mikhail Maltsev @ 2016-05-23 13:53 UTC (permalink / raw)
  To: gcc-patches, Richard Biener

Hi all!

Currently GCC generates rather bad code for the following test case:

int test(int a)
{
  return a % 2 != 0 ? 4 : 2;
}

The code looks like this:

test:
        andl    $1, %edi
        cmpl    $1, %edi
        sbbl    %eax, %eax
        andl    $-2, %eax
        addl    $4, %eax
        ret

Clang seems to generate optimal code:

test:
        andl    $1, %edi
        leal    2(%rdi,%rdi), %eax
        retq

After applying this series of 2 patches GCC generates:

test:
        movl    %edi, %eax
        andl    $1, %eax
        leal    2(%rax,%rax), %eax
        ret

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-02  9:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-23 13:53 [PATCH 0/2][GCC] Add one more pattern to RTL if-conversion Mikhail Maltsev
2016-05-23 13:58 ` [PATCH 1/2][GCC] Refactor noce_try_store_flag_constants Mikhail Maltsev
2016-06-02  9:28   ` Bernd Schmidt
2016-05-23 14:00 ` [PATCH 2/2][GCC] Add one more pattern to RTL if-conversion Mikhail Maltsev
2016-05-23 14:15   ` Kyrill Tkachov
2016-05-24 19:06     ` Mikhail Maltsev
2016-06-02  9:33       ` Bernd Schmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).