From c6ebe3fd002c1d3b903ab6e912ebd815fdb0e964 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Thu, 17 Sep 2020 09:02:26 -0400 Subject: [PATCH] [InstSimplify] add tests for FP constant miscompile; NFC (PR43907) --- llvm/test/Transforms/InstSimplify/ConstProp/cast.ll | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll b/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll index 170e2d5..b1b879d 100644 --- a/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll +++ b/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll @@ -1,3 +1,4 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -instsimplify -S | FileCheck %s ; Overflow on a float to int or int to float conversion is undefined (PR21130). @@ -38,3 +39,20 @@ define float @overflow_sitofp() { ret float %i } +; https://llvm.org/PR43907 + +define float @nan_f64_trunc() { +; CHECK-LABEL: @nan_f64_trunc( +; CHECK-NEXT: ret float 0x7FF0000000000000 +; + %f = fptrunc double 0x7FF0000000000001 to float + ret float %f +} + +define <2 x half> @nan_v2f32_trunc() { +; CHECK-LABEL: @nan_v2f32_trunc( +; CHECK-NEXT: ret <2 x half> +; + %f = fptrunc <2 x float> to <2 x half> + ret <2 x half> %f +} -- 2.7.4