<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87311>87311</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Bugs of `flang-new 19.0` concerning BFLOAT16 on MacBook Pro with M3 chip
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zaikunzhang
</td>
</tr>
</table>
<pre>
Dear LLVM flang developers and maintainers,
Thank you very much for the wonderful job.
This is a bug of flang-new 19.0.0 git (https://github.com/llvm/llvm-project.git a21e0ba192147af4968742785f375dba0e3ea768) concerning BFLOAT16 on MacBook Pro with M3 chip.
Here is a minimal example.
### Code:
```fortran
!real.f90
program real
implicit none
integer, parameter :: RP = 3 ! BFLOAT16
real(RP), parameter :: ONE = 1.0_RP
real(RP) :: h
write (*, *) range(0.0_RP), huge(0.0_RP), tiny(0.0_RP), precision(0.0_RP)
h = 0.1_RP
write (*, *) 'h = ', h
write (*, *) 'h + h = 0.2?', h + h
write (*, *) 'h * h = 0.01?', h * h
write (*, *) '1 + h*h = 1.01?', ONE + h * h
write (*,*) '(h + h) / (1 + h * h) = 0.198?', (h + h) / (ONE + h * h)
end program real
```
### Test:
```bash
% uname -a && flang-new --version && flang-new real.f90 && ./a.out
```
### Result:
```bash
Darwin 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030 arm64
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git a21e0ba192147af4968742785f375dba0e3ea768)
Target: arm64-apple-darwin23.4.0
Thread model: posix
37 3.386E+38 1.18E-38 2
h = .1
h + h = 0.2? 25.6
h * h = 0.01? 2.83
1 + h*h = 1.01? 490.
(h + h) / (1 + h * h) = 0.198? 4.06E-04
```
### N.B.
1. As you can see, addition and multiplication did not work in this example. The division seems fine.
2. May be related: when compiling this code by `flang-new real.f90`, I indeed received the following warnings about "xxx was built for newer 'macOS' version (14.3) than being linked (14.0)", even though
- I built `flang-new` on the very machine where I ran this test (using a [script](https://github.com/llvm/llvm-project/files/14831123/compile.txt)
composed according to the [official documentation](https://github.com/llvm/llvm-project/blob/main/flang/docs/GettingStarted.md))
- The version of my system `$(sw_vers -productVersion)=14.4.1`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8Vs1u4zgSfhr6UjBBUrJ-Dj7Y7Xi3sZ3pIB3MtUGJZYsTiTRIKk7msM--IGUndtIz272HBQwbrmJVffXzsSi913uDuCSLNVlsZnIMnXXLP6V-HM2fnTT7WWPVy3KD0sGXL7_fwq6XZg8Kn7C3B3QepFEwSG2C1AadJ-ITYRvCVtP3QyfNI7zYEZ7QvcAwth3srIPQIRytUeh2Yw9_2IbCtZn2oD1IaMY92N0Udm7wCLymjDLY6wBEVF0IB0-yFRFbIrZ7Hbqxoa0diNj2_dP5Z35w9g9sA41WUnBkjeS14Hkpd3ldVGUuymqxy8qFaiTDDGVZVETU0FrTojPa7GG9_fJ19cALsAZuZbu29hHunIWjDh3cZtB2-nCdxD_R4ZTEoI0eZA_4LIdDj9fHiMimD3yyCmMul8qCTZ-ddcFJczbhDmVPdzWbBAdn904OEKWTRA-HXrc6gLEGTyITcI-OiE9wkE4OGNBBjJet4P4OSLYByACI4K_JTobJq6ju74iof2j99bebZM4p-35_99HofK67TO3odMDYQyJW0Wv6qQGcNHskomKTsylkN36UBW1e3ssODlvttTVXiouoXQLKKH8F-rdoiCgnCyLKhOMnTos1nKMIkm3PlpPiZ-xXr_aMXztY_XcH_BRHnFLlV05SpyaAf-nszVck2NldFGzjIX7lIDU3FbSu3sLADy3fB7_uDBoFH-f4lQA_pswD-hAn64ecaaTvzhqxgNHIAWEugYiCiOLiTpnPn9DFqfmoOvPsrKFEbCW1Y_gpePfox_7vAU6ijXRHbUBkNKcMTv_-hc5gD7-fsE3K6GzrNNxKB3wBLAq4INlKLOBu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