public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luoyonggang at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/110921] New: Relax _tzcnt_u32 support x86, all x86 arch support for this instrunction
Date: Sun, 06 Aug 2023 14:40:23 +0000	[thread overview]
Message-ID: <bug-110921-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 110921
           Summary: Relax _tzcnt_u32 support x86, all x86 arch support for
                    this instrunction
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luoyonggang at gmail dot com
  Target Milestone: ---

Created attachment 55695
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55695&action=edit
A patch for fixes this issue in a brute way, just for demo

The compiling error:

In file included from
C:/CI-Tools/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/x86gprintrin.h:41,
                 from
C:/CI-Tools/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/x86intrin.h:27,
                 from C:/CI-Tools/msys64/mingw64/include/intrin.h:69,
                 from ../../src/amd/addrlib/src/core/addrcommon.h:33,
                 from ../../src/amd/addrlib/src/core/addrobject.h:21,
                 from ../../src/amd/addrlib/src/core/addrlib.h:21,
                 from ../../src/amd/addrlib/src/core/addrlib2.h:20,
                 from ../../src/amd/addrlib/src/gfx10/gfx10addrlib.h:19,
                 from ../../src/amd/addrlib/src/gfx10/gfx10addrlib.cpp:16:
C:/CI-Tools/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/bmiintrin.h:
In function 'unsigned int Addr::BitScanForward(unsigned int)':
C:/CI-Tools/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/13.1.0/include/bmiintrin.h:116:1:
error: inlining failed in call to 'always_inline' 'unsigned int
_tzcnt_u32(unsigned int)': target specific option mismatch
  116 | _tzcnt_u32 (unsigned int __X)
      | ^~~~~~~~~~
../../src/amd/addrlib/src/core/addrcommon.h:343:23: note: called from here
  343 |     out = ::_tzcnt_u32(mask);
      |           ~~~~~~~~~~~~^~~~~~
[113/1111] Compiling C++ object
src/amd/compiler/libaco.a.p/aco_insert_NOPs.cpp.obj

This code can be compiled with MSVC and Clang.

Reason:

Since the TZCNT instruction behaves as BSF on non-BMI targets, there is code
that expects
to use it as a potentially faster version of BSF.

This is for alignment with Clang and MSVC.

Also the _mm_tzcnt_32 and _mm_tzcnt_64 are added for consistence with Clang and
MSVC

             reply	other threads:[~2023-08-06 14:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-06 14:40 luoyonggang at gmail dot com [this message]
2023-08-06 17:32 ` [Bug target/110921] " pinskia at gcc dot gnu.org
2023-08-06 17:32 ` pinskia at gcc dot gnu.org
2023-08-07  1:27 ` crazylht at gmail dot com
2023-08-07  1:44 ` crazylht at gmail dot com
2023-08-07  1:52 ` crazylht at gmail dot com
2023-08-07  2:12 ` luoyonggang at gmail dot com
2023-08-07  2:46 ` crazylht at gmail dot com
2023-08-07 10:39 ` luoyonggang at gmail dot com
2023-08-07 11:50 ` crazylht at gmail dot com
2023-08-07 12:36 ` luoyonggang at gmail dot com
2023-08-07 12:59 ` crazylht 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-110921-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).