public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "crazylht at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/107627] New: [13] Regression int128_t shift generates extra xor/or.
Date: Fri, 11 Nov 2022 02:06:50 +0000	[thread overview]
Message-ID: <bug-107627-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107627

            Bug ID: 107627
           Summary: [13] Regression int128_t shift generates extra xor/or.
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---
            Target: x86_64-*-* i?86-*-*

The case is from PR106220.

#include<stdint.h>
static __inline
unsigned __int128 mk_u128(uint64_t hi, uint64_t lo)
{
  return ((unsigned __int128)hi << 64) | lo;
}

static __inline
uint64_t shrdq(uint64_t hi, uint64_t lo, unsigned rshift)
{
  return (uint64_t)(mk_u128(hi, lo) >> (rshift % 64));
}


void foo1to1(uint64_t *dst, const uint64_t* src, unsigned rshift)
{
  uint64_t r0 = shrdq(src[0], src[1], rshift);
  dst[0] = r0;
}


GCC trunk generates 

foo1to1:
        mov     rax, QWORD PTR [rsi]
        mov     r8, QWORD PTR [rsi+8]
        mov     ecx, edx
        xor     r9d, r9d
        mov     rdx, rax
        xor     eax, eax
        or      rax, r8
        or      rdx, r9
        shrd    rax, rdx, cl
        mov     QWORD PTR [rdi], rax

GCC12.2 generates

foo1to1:
        mov     rax, QWORD PTR [rsi+8]
        mov     r8, rdi
        mov     rdi, QWORD PTR [rsi]
        mov     ecx, edx
        shrd    rax, rdi, cl
        mov     QWORD PTR [r8], rax
        ret

             reply	other threads:[~2022-11-11  2:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11  2:06 crazylht at gmail dot com [this message]
2022-11-11  7:05 ` [Bug target/107627] " crazylht at gmail dot com
2022-11-11  7:09 ` [Bug target/107627] [13 Regression] " pinskia at gcc dot gnu.org
2022-11-11  9:41 ` rguenth at gcc dot gnu.org
2022-11-21 10:34 ` marxin at gcc dot gnu.org
2022-11-22 12:52 ` jakub at gcc dot gnu.org
2022-11-25 23:40 ` roger at nextmovesoftware dot com
2022-11-29 19:12 ` jakub at gcc dot gnu.org
2022-11-29 19:55 ` jakub at gcc dot gnu.org
2022-11-30 13:03 ` jakub at gcc dot gnu.org
2022-12-01  8:35 ` cvs-commit at gcc dot gnu.org
2022-12-01  8:36 ` jakub at gcc dot gnu.org
2022-12-07 14:31 ` jakub at gcc dot gnu.org
2022-12-08 13:57 ` cvs-commit at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-107627-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).