public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/101175] builtin_clz generates wrong bsr instruction
Date: Wed, 23 Jun 2021 08:35:51 +0000	[thread overview]
Message-ID: <bug-101175-4-nK3Kh697s3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101175-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Mikael Pettersson from comment #2)
> (In reply to Iru Cai from comment #0)
> > Built with '-march=x86-64-v3 -O1', the following code generates a bsr
> > instruction, which has undefined behavior when the source operand is zero,
> > thus gives wrong result
> 
> The documentation for __builtin_clz(x) states "If x is 0, the result is
> undefined".

The testcase from Comment #0 does:

        if (value != 0) {
                return __builtin_clz(value);

  parent reply	other threads:[~2021-06-23  8:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23  5:56 [Bug target/101175] New: " mytbk920423 at gmail dot com
2021-06-23  7:33 ` [Bug target/101175] " ubizjak at gmail dot com
2021-06-23  8:33 ` mikpelinux at gmail dot com
2021-06-23  8:35 ` ubizjak at gmail dot com [this message]
2021-06-23  8:38 ` mikpelinux at gmail dot com
2021-06-23 10:51 ` cvs-commit at gcc dot gnu.org
2021-06-23 18:11 ` cvs-commit at gcc dot gnu.org
2021-06-24  6:17 ` cvs-commit at gcc dot gnu.org
2021-06-24  6:17 ` cvs-commit at gcc dot gnu.org
2021-06-24  6:18 ` ubizjak at gmail dot com

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-101175-4-nK3Kh697s3@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).