Skip to content

Commit abb21b5

Browse files
committed
[ConstProp] add tests for APFloat truncate miscompile; NFC
issue #55838
1 parent 332d520 commit abb21b5

File tree

1 file changed

+46
-0
lines changed
  • llvm/test/Transforms/InstSimplify/ConstProp

1 file changed

+46
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,49 @@ define bfloat @nan_bf16_trunc() {
7070
%f = fptrunc double 0x7FF0000000000001 to bfloat
7171
ret bfloat %f
7272
}
73+
74+
define float @trunc_denorm_lost_fraction0() {
75+
; CHECK-LABEL: @trunc_denorm_lost_fraction0(
76+
; CHECK-NEXT: ret float 0.000000e+00
77+
;
78+
%b = fptrunc double 0x0000000010000000 to float
79+
ret float %b
80+
}
81+
82+
; FIXME: This should be 0.0.
83+
84+
define float @trunc_denorm_lost_fraction1() {
85+
; CHECK-LABEL: @trunc_denorm_lost_fraction1(
86+
; CHECK-NEXT: ret float 0x36A0000000000000
87+
;
88+
%b = fptrunc double 0x0000000010000001 to float
89+
ret float %b
90+
}
91+
92+
; FIXME: This should be 0.0.
93+
94+
define float @trunc_denorm_lost_fraction2() {
95+
; CHECK-LABEL: @trunc_denorm_lost_fraction2(
96+
; CHECK-NEXT: ret float 0x36A0000000000000
97+
;
98+
%b = fptrunc double 0x000000001fffffff to float
99+
ret float %b
100+
}
101+
102+
define float @trunc_denorm_lost_fraction3() {
103+
; CHECK-LABEL: @trunc_denorm_lost_fraction3(
104+
; CHECK-NEXT: ret float 0.000000e+00
105+
;
106+
%b = fptrunc double 0x0000000020000000 to float
107+
ret float %b
108+
}
109+
110+
; FIXME: This should be -0.0.
111+
112+
define float @trunc_denorm_lost_fraction4() {
113+
; CHECK-LABEL: @trunc_denorm_lost_fraction4(
114+
; CHECK-NEXT: ret float 0xB6A0000000000000
115+
;
116+
%b = fptrunc double 0x8000000010000001 to float
117+
ret float %b
118+
}

0 commit comments

Comments
 (0)