public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114921] New: Optimization flags cause _Float16 to __bf16 casting to do nothing
@ 2024-05-02 10:17 mat.mcroci at gmail dot com
  2024-05-02 11:42 ` [Bug c++/114921] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mat.mcroci at gmail dot com @ 2024-05-02 10:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114921
           Summary: Optimization flags cause _Float16 to __bf16 casting to
                    do nothing
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mat.mcroci at gmail dot com
  Target Milestone: ---

When compiling the following code (assuming it's in a file called test.cpp)

#include <stdlib.h>
#include <cstdint>
#include <array>
#include <iostream>

#define SIZE 8

typedef _Float16 T;
//typedef volatile float T;

void fp16tobf16(_Float16 * f) {
        __bf16 * b = reinterpret_cast<__bf16*>(f);
        for(int i=0; i<SIZE; i++){
            T temp = f[i];
            b[i] = (__bf16) temp;
        }
}

with:

g++ -c -S -O2 -std=c++23 -o test.s test.cpp

using gcc 13.2.0 compiled with binutils 2.42 using spack, the assembler does
not do any casting and simply returns. You can also check this behaviour on
godbolt. The resulting assembly code is simply

fp16tobf16(_Float16*):
        ret

When using -O1 or -O0, the assembler generates the command __extendhfbf2 which
causes a separate issue, which is related to this bug:

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

P.s. I reported this bug in binutils already, but they suggested I reported it
here instead, see

https://sourceware.org/bugzilla/show_bug.cgi?id=31685

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-29  6:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-02 10:17 [Bug c++/114921] New: Optimization flags cause _Float16 to __bf16 casting to do nothing mat.mcroci at gmail dot com
2024-05-02 11:42 ` [Bug c++/114921] " rguenth at gcc dot gnu.org
2024-05-03  6:20 ` cvs-commit at gcc dot gnu.org
2024-05-03  7:28 ` [Bug tree-optimization/114921] " cvs-commit at gcc dot gnu.org
2024-05-07  6:26 ` cvs-commit at gcc dot gnu.org
2024-05-29  6:29 ` cvs-commit at gcc dot gnu.org

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).