Repository: rust
Issue: f64::round doesn't work properly on arm-unknown-linux-gnueabi
Labels: A-LLVM,O-Arm,P-high,T-compiler,I-unsound,C-bug,I-miscompile,E-needs-investigation

I'm cross-compiling for target `arm-unknown-linux-gnueabi`, and I encountered that `f64::round()` does not work correctly. I tried this code:

```rust
fn main() {
    let value: f64 = 15.44;
    dbg!(value);
    dbg!(value.round());
}
```

I expected to see:

```
[bug/src/main.rs:3:5] value = 15.44
[bug/src/main.rs:4:5] value.round() = 15.0
```

But instead, in the debug build I see:

```
[bug/src/main.rs:3:5] value = 15.44
[bug/src/main.rs:4:5] value.round() = 0.0
```

In the release build, as a rule, the output is correct, but *sometimes* `f64::round()`  returning 0 or 1 instead of the correct rounding. I can't reliably reproduce this bug in release build.

I build this code in docker container. See more details under the spoiler.

<details>
  <summary>Build details</summary>
  
  I build code with this command:

  ```sh
  docker build -f Dockerfile -t build_image .

  docker run \
    -v $HOME/.cargo/registry:/root/.cargo/registry \
    -v $(pwd):/src \
    -t build_image
  ```

  `Dockerfile`:

  ```Dockerfile
  FROM debian:11-slim
  
  # Install Rust
  RUN apt-get update && apt-get install -y curl
  RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
  ENV PATH="/root/.cargo/bin:${PATH}"
  
  # Install tools
  RUN apt-get update && apt-get install -y \
      crossbuild-essential-armel
  
  # Install target for ARMv6
  RUN rustup target add arm-unknown-linux-gnueabi
  
  # Build
  RUN mkdir -p /src
  WORKDIR /src

  # Remove --release for debug build
  CMD cargo build --release --target=arm-unknown-linux-gnueabi
  ```
 
  `Cargo.toml`:

  ```toml
  [package]
  name = "bug"
  version = "0.1.0"
  edition = "2021"
  
  [dependencies]
  
  [profile.release]
  opt-level = 3
  strip = "debuginfo"
  panic = "abort"
  ```

  `.cargo/config.toml`:

  ```toml
  [target.arm-unknown-linux-gnueabi]
  linker = "arm-linux-gnueabi-gcc"
  rustflags = ["-L", "/usr/lib/arm-linux-gnueabi"]
  ```
  
</details>

[binaries.tar.gz](https://github.com/rust-lang/rust/files/14550591/binaries.tar.gz)
[source.tar.gz](https://github.com/rust-lang/rust/files/14550593/source.tar.gz)

### Meta

`rustc --version --verbose`:

```
rustc 1.76.0 (07dca489a 2024-02-04)                                                                                                                                                           
binary: rustc                                                                                                                                                                                 
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce                                                                                                                                         
commit-date: 2024-02-04                                                                                                                                                                       
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6
```