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 tree-optimization/105735] New: GCC failed to reduce &= loop_inv in loop.
Date: Thu, 26 May 2022 07:54:55 +0000	[thread overview]
Message-ID: <bug-105735-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 105735
           Summary: GCC failed to reduce &= loop_inv in loop.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

This is another case from 47769, similar like 103462, but a little different.


unsigned long cfunc_one(unsigned long tmp, unsigned long bit2) {
    for (unsigned long bit = 0; bit < 64; bit++) {
        tmp &= bit2;
    }
    return tmp;
}


it should be equal to

unsigned long cfunc_one(unsigned long tmp, unsigned long bit2) {
   tmp &= bit2;
   return tmp;
}

but gcc generates a loop.

cfunc_one(unsigned long, unsigned long):
        mov     eax, 64
.L2:
        and     rdi, rsi
        dec     rax
        jne     .L2
        mov     rax, rdi
        ret

Similar for |= and ^=.

             reply	other threads:[~2022-05-26  7:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26  7:54 crazylht at gmail dot com [this message]
2022-05-26  8:29 ` [Bug tree-optimization/105735] " pinskia at gcc dot gnu.org
2022-09-20  6:36 ` cvs-commit at gcc dot gnu.org
2022-09-22  2:04 ` lingling.kong7 at gmail dot com
2023-11-14  1:28 ` 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-105735-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).