[llvm] abb21b5 - [ConstProp] add tests for APFloat truncate miscompile; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 5 17:09:17 PDT 2022


Author: Sanjay Patel
Date: 2022-06-05T20:07:18-04:00
New Revision: abb21b54bc83698cf4705928ef7e0155b7587e2b

URL: https://github.com/llvm/llvm-project/commit/abb21b54bc83698cf4705928ef7e0155b7587e2b
DIFF: https://github.com/llvm/llvm-project/commit/abb21b54bc83698cf4705928ef7e0155b7587e2b.diff

LOG: [ConstProp] add tests for APFloat truncate miscompile; NFC

issue #55838

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/ConstProp/cast.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll b/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll
index 14eb29e636c6f..b977ef544090b 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/cast.ll
@@ -70,3 +70,49 @@ define bfloat @nan_bf16_trunc() {
   %f = fptrunc double 0x7FF0000000000001 to bfloat
   ret bfloat %f
 }
+
+define float @trunc_denorm_lost_fraction0() {
+; CHECK-LABEL: @trunc_denorm_lost_fraction0(
+; CHECK-NEXT:    ret float 0.000000e+00
+;
+  %b = fptrunc double 0x0000000010000000 to float
+  ret float %b
+}
+
+; FIXME: This should be 0.0.
+
+define float @trunc_denorm_lost_fraction1() {
+; CHECK-LABEL: @trunc_denorm_lost_fraction1(
+; CHECK-NEXT:    ret float 0x36A0000000000000
+;
+  %b = fptrunc double 0x0000000010000001 to float
+  ret float %b
+}
+
+; FIXME: This should be 0.0.
+
+define float @trunc_denorm_lost_fraction2() {
+; CHECK-LABEL: @trunc_denorm_lost_fraction2(
+; CHECK-NEXT:    ret float 0x36A0000000000000
+;
+  %b = fptrunc double 0x000000001fffffff to float
+  ret float %b
+}
+
+define float @trunc_denorm_lost_fraction3() {
+; CHECK-LABEL: @trunc_denorm_lost_fraction3(
+; CHECK-NEXT:    ret float 0.000000e+00
+;
+  %b = fptrunc double 0x0000000020000000 to float
+  ret float %b
+}
+
+; FIXME: This should be -0.0.
+
+define float @trunc_denorm_lost_fraction4() {
+; CHECK-LABEL: @trunc_denorm_lost_fraction4(
+; CHECK-NEXT:    ret float 0xB6A0000000000000
+;
+  %b = fptrunc double 0x8000000010000001 to float
+  ret float %b
+}


        


More information about the llvm-commits mailing list