fix implement IEEE NaN signaling bit
MODIFY
ir/type.cpp
ir/type.cpp
@@ -460,11 +460,15 @@ expr FloatType::isNaN(const expr &v, bool signalling) const {
unsigned fraction_bits = bits() - exp_bits - 1;
expr exponent = v.extract(fraction_bits + exp_bits - 1, fraction_bits);
+ expr nanqbit = exponent.extract(exp_bits - 1, exp_bits - 1);
+ expr isqnan;
+ if (signalling) {
expr fraction = v.extract(fraction_bits - 1, 0);
- expr isqnan = expr::mkUF("isQNaN", { fraction }, false);
- if (signalling)
- isqnan = !isqnan;
- return exponent == -1u && fraction != 0 && isqnan;
+ isqnan = nanqbit == 0 && fraction != 0;
+ } else {
+ isqnan = nanqbit == 1;
+ }
+ return exponent == -1u && isqnan;
}
unsigned FloatType::bits() const {

ADD
tests/alive-tv/fp/fpclass-qnan.srctgt.ll
+define i1 @src() {
+ %val = call i1 @llvm.is.fpclass.f64(double 0x7FF8000000000000, i32 2)
+ ret i1 %val
+}
+
+define i1 @tgt() {
+ ret i1 true
+}
+
+declare i1 @llvm.is.fpclass.f64(double, i32 immarg)

fix #864: implement IEEE 754-2008 NaN signaling bit