Issue 87311
Summary Bugs of `flang-new 19.0` concerning BFLOAT16 on MacBook Pro with M3 chip
Labels new issue
Assignees
Reporter zaikunzhang
    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`
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to