[PATCH, i386]: Implement SImode/DImode setcc insn patterns

Uros Bizjak ubizjak@gmail.com
Sat Oct 10 20:16:00 GMT 2009


Hello!

There is the %%% TODO mark in i386.md, present there probably for ages, 
where it is suggested to implement setcc patterns for SImode/DImode (aka 
word_mode). As can be seen from following example, combine & co. cries 
for these patterns...

The testcase:

int test (__float128 a)
{
   return a != 0;
}

gcc -O2 -m64:

test:
     pxor    %xmm1, %xmm1
     pushq    %rbx
     xorl    %ebx, %ebx
     call    __netf2
     testq    %rax, %rax
     movl    $1, %eax
     cmovne    %eax, %ebx
     movl    %ebx, %eax
     popq    %rbx
     ret

Middle end expands FP compare to something that resembles cmove. TFmode 
compares are implemented using a libcall, where the call breaks wanna-be 
setcc sequence. And when combine comes around, it tries to combine 
several instruction in the above code to construct word_mode setcc insn 
- which is not present in the target *.md file. And due to expanded 
sequence, we have a register that lives across the call (%rbx), so RA 
allocates call-saved register ...

By providing word_mode setcc insns, the code becomes much shorter:

test:
     pxor    %xmm1, %xmm1
     subq    $8, %rsp
     call    __netf2
     testq    %rax, %rax
     setne    %dl
     addq    $8, %rsp
     movzbl    %dl, %eax
     ret

And for TARGET_PARTIAL_REG_STALL:

     ...
     call    __netf2
     xorl    %eax, %eax
     leave
     setne    %al
     ret

2009-10-10  Uros Bizjak <ubizjak@gmail.com>

     * config/i386/i386.md (*setcc_di_1): New insn_and_split pattern.
     (*setcc_si_1): Ditto.
     (*setcc_<mode>_2): Ditto.
     (*setcc_qi): Rename from *setcc_1.
     (*setcc_qi_slp): Rename from *setcc_2.

     * config/i386/i386.c (ix86_expand_clear): Remove reload_completed from
     "if" condition, there is already assert with reload_completed present.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32}.

I know it is late in the game, but the code is so much better, so if 
nobody will object, I'll try to sneak the code to mainline SVN.

Uros.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091010/3c147cf4/attachment.txt>


More information about the Gcc-patches mailing list