diff options
| -rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | 9 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WebAssembly/immediates.ll | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp index 35a4be3805d..1c24e445a92 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -117,10 +117,11 @@ void WebAssemblyAsmPrinter::EmitInstruction(const MachineInstr *MI) { static const size_t BufBytes = 128; char buf[BufBytes]; APFloat FP = MO.getFPImm()->getValueAPF(); - const APFloat CanonicalNaN = APFloat::getQNaN(FP.getSemantics()); - if (FP.isNaN() && !FP.bitwiseIsEqual(CanonicalNaN)) - // WebAssembly only has NaNs that are positive, quiet, without payload. - FP = CanonicalNaN; + if (FP.isNaN()) + assert((FP.bitwiseIsEqual(APFloat::getQNaN(FP.getSemantics())) || + FP.bitwiseIsEqual( + APFloat::getQNaN(FP.getSemantics(), /*Negative=*/true))) && + "convertToHexString handles neither SNaN nor NaN payloads"); // Use C99's hexadecimal floating-point representation. auto Written = FP.convertToHexString(buf, /*hexDigits=*/0, /*upperCase=*/false, diff --git a/llvm/test/CodeGen/WebAssembly/immediates.ll b/llvm/test/CodeGen/WebAssembly/immediates.ll index f22e2943466..1059ffcea30 100644 --- a/llvm/test/CodeGen/WebAssembly/immediates.ll +++ b/llvm/test/CodeGen/WebAssembly/immediates.ll @@ -97,7 +97,7 @@ define float @nan_f32() { } ; CHECK-LABEL: negnan_f32: -; CHECK-NEXT: (setlocal @0 (immediate nan)) +; CHECK-NEXT: (setlocal @0 (immediate -nan)) ; CHECK-NEXT: (return @0) define float @negnan_f32() { ret float 0xFFF8000000000000 @@ -153,7 +153,7 @@ define double @nan_f64() { } ; CHECK-LABEL: negnan_f64: -; CHECK-NEXT: (setlocal @0 (immediate nan)) +; CHECK-NEXT: (setlocal @0 (immediate -nan)) ; CHECK-NEXT: (return @0) define double @negnan_f64() { ret double 0xFFF8000000000000 |

