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.
problem
the
__builtin_isnormalfunction forf16types will generate code that produces wrong results.test program
expected result
This should return a
0as the calculation result is not_normal. On s390x this produces a1analysis
the generated code calls
__extendhfsf2before issuingtceb1. however extending af16will not preserve all information. A number that fails theisnormalas f16 might pass it asf32. The backend needs to check if extending will loose information and issue code that works around it.Footnotes
tceb(TEST DATA CLASS) is a hardware specific instruction that can execute multiple float tests at once. ↩