Skip to content

f16::is_normal broken on s390x #154101

@fneddy

Description

@fneddy

I tried this code on s390x:

./x test tests/ui/float/classify-runtime-const.rs

the failing case condensed is:

#![feature(f16)]
use std::hint::black_box;
use std::process::ExitCode;

fn main() -> ExitCode {
    ExitCode::from(f16::is_normal (1.0 / black_box(f16::MAX)) as u8)
}

I expected to see this happen:
the program should return a 0 because the calculation result is not_normal

Instead, this happened:
with -O (or -C opt-level=3) I see a 1 instead of a 0

Analysis

this is due to a bug in the llvm backend1. llvm will issue f16 expand instructions that will loose information.

Steps

f16 is feature gated. I guess for now its ok to emit wrong code for f16::is_normal + -C opt-level=3?

We are working on fixing the bug in the llvm backend. with the next backend update it should be fixed.

Footnotes

  1. https://github.com/llvm/llvm-project/issues/187518

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]`I-miscompileIssue: Correct Rust code lowers to incorrect machine codellvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions