This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/78037] Incorrect code generated at optimization level -O2 for tzcnt and binary and


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |uros at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That is because _tzcnt_u64 is expanded as __builtin_ctzll, which is explicitly
UB with zero argument.  So, either we need to expand it like
x ? __builtin_ctzll (x) : 64 and make sure at RTL level we optimize this into
just tzcnt instruction if available (though, that is questionable, because if
you run tzcntq instruction on non-BMI CPUs, it will just be BSF with undefined
result for 0), or add a new builtin, or unconditionally expand to the
conditional.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]