Skip to content

f16 is_normal broken on s390x #187518

@fneddy

Description

@fneddy

problem

the __builtin_isnormal function for f16 types will generate code that produces wrong results.

test program

#include <cmath>

int main() {
    volatile _Float16 max = __FLT16_MAX__;
    _Float16 x = (_Float16)1.0 / max;

    return (int)__builtin_isnormal(x);
}

expected result

This should return a 0 as the calculation result is not_normal. On s390x this produces a 1

analysis

the generated code calls __extendhfsf2 before issuing tceb1. however extending a f16 will not preserve all information. A number that fails the isnormal as f16 might pass it as f32. The backend needs to check if extending will loose information and issue code that works around it.

Footnotes

  1. tceb (TEST DATA CLASS) is a hardware specific instruction that can execute multiple float tests at once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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