File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3287,15 +3287,24 @@ pub const DeclGen = struct {
32873287 .Float = > {
32883288 const llvm_ty = try dg .lowerType (tv .ty );
32893289 switch (tv .ty .floatBits (target )) {
3290- 16 = > if (intrinsicsAllowed (tv .ty , target )) {
3291- return llvm_ty .constReal (tv .val .toFloat (f16 ));
3292- } else {
3290+ 16 = > {
32933291 const repr = @bitCast (u16 , tv .val .toFloat (f16 ));
32943292 const llvm_i16 = dg .context .intType (16 );
32953293 const int = llvm_i16 .constInt (repr , .False );
32963294 return int .constBitCast (llvm_ty );
32973295 },
3298- 32 , 64 = > return llvm_ty .constReal (tv .val .toFloat (f64 )),
3296+ 32 = > {
3297+ const repr = @bitCast (u32 , tv .val .toFloat (f32 ));
3298+ const llvm_i32 = dg .context .intType (32 );
3299+ const int = llvm_i32 .constInt (repr , .False );
3300+ return int .constBitCast (llvm_ty );
3301+ },
3302+ 64 = > {
3303+ const repr = @bitCast (u64 , tv .val .toFloat (f64 ));
3304+ const llvm_i64 = dg .context .intType (64 );
3305+ const int = llvm_i64 .constInt (repr , .False );
3306+ return int .constBitCast (llvm_ty );
3307+ },
32993308 80 = > {
33003309 const float = tv .val .toFloat (f80 );
33013310 const repr = std .math .break_f80 (float );
Original file line number Diff line number Diff line change @@ -241,6 +241,7 @@ test {
241241 {
242242 _ = @import ("behavior/bugs/13063.zig" );
243243 _ = @import ("behavior/bugs/11227.zig" );
244+ _ = @import ("behavior/bugs/14198.zig" );
244245 _ = @import ("behavior/export.zig" );
245246 }
246247
Original file line number Diff line number Diff line change 1+ const std = @import ("std" );
2+ const math = std .math ;
3+ const mem = std .mem ;
4+ const testing = std .testing ;
5+
6+ test "nan memory equality" {
7+ // signaled
8+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .nan_u16 ), mem .asBytes (& math .nan_f16 )));
9+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .nan_u32 ), mem .asBytes (& math .nan_f32 )));
10+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .nan_u64 ), mem .asBytes (& math .nan_f64 )));
11+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .nan_u128 ), mem .asBytes (& math .nan_f128 )));
12+
13+ // quiet
14+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .qnan_u16 ), mem .asBytes (& math .qnan_f16 )));
15+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .qnan_u32 ), mem .asBytes (& math .qnan_f32 )));
16+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .qnan_u64 ), mem .asBytes (& math .qnan_f64 )));
17+ try testing .expect (mem .eql (u8 , mem .asBytes (& math .qnan_u128 ), mem .asBytes (& math .qnan_f128 )));
18+ }
You can’t perform that action at this time.
0 commit comments