]> git.ipfire.org Git - thirdparty/gcc.git/commit
Use ix86_expand_clear in ix86_split_ashl.
authorRoger Sayle <roger@nextmovesoftware.com>
Wed, 28 Dec 2022 19:27:52 +0000 (19:27 +0000)
committerRoger Sayle <roger@nextmovesoftware.com>
Wed, 28 Dec 2022 19:27:52 +0000 (19:27 +0000)
commit38b649ec16c965733aab9efa6bf61faae3485d92
tree1de2ca386624ccfb3824eec791dff1a5375ee333
parentd898a17b927531bbc0de7ad0991dc3c96915d67d
Use ix86_expand_clear in ix86_split_ashl.

This patch is a one line change, to call ix86_expand_clear instead of
emit_move_insn with const0_rtx in ix86_split_ashl, allowing the backend
to use an xor instruction to clear a register if appropriate.

The effect is demonstrated with the following function.
__int128 foo(__int128 x, unsigned long long b) {
    return ((__int128)b << 72) + x;
}

previously with -O2, GCC would generate

foo:    movl    $0, %eax
        salq    $8, %rdx
        addq    %rdi, %rax
        adcq    %rsi, %rdx
        ret

with this patch, it now generates

foo:    xorl    %eax, %eax
        salq    $8, %rdx
        addq    %rdi, %rax
        adcq    %rsi, %rdx
        ret

2022-12-28  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/i386/i386-expand.cc (ix86_split_ashl): Call
ix86_expand_clear to generate an xor instruction.

gcc/testsuite/ChangeLog
* gcc.target/i386/ashlti3-1.c: New test case.
gcc/config/i386/i386-expand.cc
gcc/testsuite/gcc.target/i386/ashlti3-1.c [new file with mode: 0644]